From ef8e6750a0b792937377fe97dcb56d737d90a039 Mon Sep 17 00:00:00 2001 From: ZhengYang Date: Thu, 14 Aug 2014 13:10:42 +0800 Subject: [PATCH] halt when there is nothing to rollback --- migrate.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/migrate.go b/migrate.go index c65fae7..afe4257 100644 --- a/migrate.go +++ b/migrate.go @@ -152,6 +152,10 @@ func migrate(goal, crupath, driver, connStr string) { defer db.Close() checkForSchemaUpdateTable(db) latestName, latestTime := getLatestMigration(db) + if goal == "rollback" && latestName == "" { + ColorLog("[ERRO] There is nothing to rollback\n") + os.Exit(2) + } writeMigrationSourceFile(dir, source, driver, connStr, latestTime, latestName, goal) buildMigrationBinary(dir, binary) runMigrationBinary(dir, binary)