diff --git a/README.md b/README.md index 2f0f60c25..28f9ddf67 100644 --- a/README.md +++ b/README.md @@ -338,6 +338,9 @@ func Down(tx *sql.Tx) error { } ``` +Note that Go migration files must begin with a numeric value, followed by an +underscore, and must not end with `*_test.go`. + # Development This can be used to build local `goose` binaries without having the latest Go version installed locally. diff --git a/migrate.go b/migrate.go index c92f7a8a2..02da090df 100644 --- a/migrate.go +++ b/migrate.go @@ -9,6 +9,7 @@ import ( "path" "runtime" "sort" + "strings" "time" ) @@ -234,6 +235,10 @@ func collectMigrationsFS(fsys fs.FS, dirpath string, current, target int64) (Mig continue // Skip any files that don't have version prefix. } + if strings.HasSuffix(file, "_test.go") { + continue // Skip Go test files. + } + // Skip migrations already existing migrations registered via goose.AddMigration(). if _, ok := registeredGoMigrations[v]; ok { continue