fix: exclude Go test files from migrations ()

pull/475/head
ipoerner 2023-03-04 18:48:57 +01:00 committed by GitHub
parent 0af59c1a4e
commit b62288d2fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -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.

View File

@ -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