Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

Commit

Permalink
DownTo returns error if no matching migration file is found (pressly#314
Browse files Browse the repository at this point in the history
)
  • Loading branch information
briskt authored Feb 21, 2022
1 parent b51d501 commit 630ef77
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions down.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 630ef77

Please sign in to comment.