DownTo returns error if no matching migration file is found (#314)

pull/315/head
Schparky 2022-02-21 16:36:57 -07:00 committed by GitHub
parent b51d50131b
commit 630ef77c33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -54,11 +54,15 @@ func DownTo(db *sql.DB, dir string, version int64, opts ...OptionsFunc) error {
return err
}
current, err := migrations.Current(currentVersion)
if err != nil {
if currentVersion == 0 {
log.Printf("goose: no migrations to run. current version: %d\n", currentVersion)
return nil
}
current, err := migrations.Current(currentVersion)
if err != nil {
log.Printf("goose: migration file not found for current version (%d), error: %s\n", currentVersion, err)
return err
}
if current.Version <= version {
log.Printf("goose: no migrations to run. current version: %d\n", currentVersion)