migration sql: error out if no annotations are found, rather than marking the migration as having run successfully.

pull/2/head
Liam Staskawicz 2013-04-07 16:55:13 -07:00
parent 09e81b9cb9
commit c9a4615595
1 changed files with 6 additions and 5 deletions

View File

@ -65,16 +65,17 @@ func runSQLMigration(db *sql.DB, script string, v int64, direction bool) error {
}
}
if err = finalizeMigration(txn, direction, v); err != nil {
log.Fatalf("error finalizing migration %s, quitting. (%v)", filepath.Base(script), err)
}
if upSections == 0 && downSections == 0 {
log.Printf(`WARNING: no Up/Down annotations found in %s, so no statements were executed.
txn.Rollback()
log.Fatalf(`ERROR: no Up/Down annotations found in %s, so no statements were executed.
See https://bitbucket.org/liamstask/goose/overview for details.`,
filepath.Base(script))
}
if err = finalizeMigration(txn, direction, v); err != nil {
log.Fatalf("error finalizing migration %s, quitting. (%v)", filepath.Base(script), err)
}
return nil
}