mirror of https://github.com/pressly/goose.git
fix: exclude Go test files from migrations (#474)
parent
0af59c1a4e
commit
b62288d2fe
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue