halt when there is nothing to rollback

This commit is contained in:
ZhengYang 2014-08-14 13:10:42 +08:00
parent 923a02f99b
commit ef8e6750a0
1 changed files with 4 additions and 0 deletions

View File

@ -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)