refactor(cli): flat migrations layout + filename-encoded plugin attribution - #33
Merged
Conversation
…bution Closes #32. Breaking change (pre-v1) — migration files now live in a single flat directory with the plugin name encoded in each filename: 20260520120000_core_initial.up.sql 20260520130000_username_add_username.up.sql This matches the conventions of golang-migrate, goose, atlas, Rails, and Prisma. The previous nested per-plugin layout (./plugins/<name>/migrations/) is no longer supported. Steps from #32: - R1 Rename source migration files (core + username) to <ts>_<plugin>_<name> - R2-R3 discovery.go walks only core_dir, parses plugin from filename via regex `^(\d{14})_([a-z][a-z0-9]*)_(.+)\.up\.sql$` - R4 init.go writes all files (core + plugins) to cfg.Migrations.CoreDir - R5 JSON Schema: migrations.plugins[] is now strictly shorthand names - R6-R7 New scan.go: walks user's *.go files for plugin imports, warns when those drift from migrations.plugins. --no-scan opts out. - R8 Tests updated for new filenames; new scan tests added; resolvePluginEntry test removed (function dropped — no longer needed without path form) - R9 examples/basic config switched to shorthand; ./migrations/ regenerated by `make example` via `goten init`; gitignored - R10 CHANGELOG breaking-change section Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #32.
Summary
Migration files now live in a single flat directory with the plugin name encoded in each filename. This matches the conventions of golang-migrate, goose, atlas, Rails, and Prisma.
Before (nested):
After (flat):
Breaking change (pre-v1)
migrations.plugins[]ingoten.config.yamlis now strictly a list of plugin shorthand names (- username). Explicit-path entries (- ./plugins/username/migrations) are no longer accepted.goten init(or rename manually).What's in the PR
*_core_*) + username plugin (*_username_*).discovery.go: walks onlycfg.Migrations.CoreDir; parses plugin from filename via regex^(\d{14})_([a-z][a-z0-9]*)_(.+)\.up\.sql$. Files that don't match the pattern are skipped.init.go: writes both core and plugin SQL files tocfg.Migrations.CoreDir. No more per-plugin destination subdirs.goten.config.schema.json):migrations.plugins[]items now restricted by regex to lowercase shorthand names.cmd/goten/scan.go: parses user's*.gofiles (parser.ImportsOnly), finds imports undergithub.com/dnahilman/goten/plugins/, warns when those drift frommigrations.plugins. Skipped dirs:vendor,.git,.claude,node_modules,testdata. Honors blank imports. Opt out with--no-scan.resolvePluginEntryand its test (function dropped — no longer needed without path form).examples/basic/goten.config.yamlswitched to shorthand.examples/basic/migrations/is now.gitignored and regenerated bymake exampleviagoten init. Integration test (test/adapters/gorm/adapter_test.go) updated to read the renamed core file.[Unreleased]Breaking-change section + Added section.Test plan
make build— all six modules compile.go test ./internal/...— unit tests pass.cd test && go test ./...— handlers/session/crypto + adapters/gorm/integration + plugins/username all pass with renamed files.cd cmd/goten && go test ./...— 18 tests pass (init + discovery + scan + config).mktemp -d → echo config withplugins: [username]→ goten init --no-scan→ confirm 4 files in flat./migrations/, no./plugins/directory created. Output:test/adapters/gorm/adapter_test.go:32.Follow-up
Wiki Quick Start §5 diagram update is the last step of #32 and will land as a wiki commit immediately after this PR merges.
🤖 Generated with Claude Code