mirror of
https://github.com/pressly/goose.git
synced 2025-05-31 11:42:04 +00:00
Merge pull request #48 from nkovacs/47-migrate-to-0
Allow down-to to roll back first version
This commit is contained in:
commit
43bbf73c63
16
down.go
16
down.go
@ -38,23 +38,15 @@ func DownTo(db *sql.DB, dir string, version int64) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
prev, err := migrations.Previous(currentVersion)
|
current, err := migrations.Current(currentVersion)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == ErrNoNextVersion {
|
|
||||||
fmt.Printf("goose: no migrations to run. current version: %d\n", currentVersion)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if prev.Version < version {
|
|
||||||
fmt.Printf("goose: no migrations to run. current version: %d\n", currentVersion)
|
fmt.Printf("goose: no migrations to run. current version: %d\n", currentVersion)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
current, err := migrations.Current(currentVersion)
|
if current.Version <= version {
|
||||||
if err != nil {
|
fmt.Printf("goose: no migrations to run. current version: %d\n", currentVersion)
|
||||||
return fmt.Errorf("no migration %v", currentVersion)
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = current.Down(db); err != nil {
|
if err = current.Down(db); err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user