From 602cd2b9c7f14425978214f809d0f34e4a40c38c Mon Sep 17 00:00:00 2001 From: "Vojtech Vitek (V-Teq)" Date: Mon, 20 Jun 2016 15:56:01 -0400 Subject: [PATCH] Fix up-by-one and down cmd return err --- down.go | 8 ++++++++ up.go | 10 +++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/down.go b/down.go index 43a9f9d..3b5835c 100644 --- a/down.go +++ b/down.go @@ -2,6 +2,7 @@ package goose import ( "database/sql" + "fmt" ) func Down(db *sql.DB, dir string) error { @@ -12,6 +13,13 @@ func Down(db *sql.DB, dir string) error { previous, err := GetPreviousDBVersion(dir, current) if err != nil { + if err != nil { + if err == ErrNoPreviousVersion { + fmt.Printf("goose: no migrations to run. current version: %d\n", current) + } + return err + } + return err } diff --git a/up.go b/up.go index 6788164..f1b348d 100644 --- a/up.go +++ b/up.go @@ -2,6 +2,7 @@ package goose import ( "database/sql" + "fmt" ) func Up(db *sql.DB, dir string) error { @@ -22,7 +23,14 @@ func UpByOne(db *sql.DB, dir string) error { return err } - next, _ := GetNextDBVersion(dir, current) + next, err := GetNextDBVersion(dir, current) + if err != nil { + if err == ErrNoNextVersion { + fmt.Printf("goose: no migrations to run. current version: %d\n", current) + } + return err + } + if err = RunMigrations(db, dir, next); err != nil { return err }