1
0
mirror of https://github.com/beego/bee.git synced 2024-11-25 20:10:55 +00:00

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

View File

@ -152,6 +152,10 @@ func migrate(goal, crupath, driver, connStr string) {
defer db.Close() defer db.Close()
checkForSchemaUpdateTable(db) checkForSchemaUpdateTable(db)
latestName, latestTime := getLatestMigration(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) writeMigrationSourceFile(dir, source, driver, connStr, latestTime, latestName, goal)
buildMigrationBinary(dir, binary) buildMigrationBinary(dir, binary)
runMigrationBinary(dir, binary) runMigrationBinary(dir, binary)