From c9a4615595e0a980399530acc68d334ec4af57d3 Mon Sep 17 00:00:00 2001 From: Liam Staskawicz Date: Sun, 7 Apr 2013 16:55:13 -0700 Subject: [PATCH] migration sql: error out if no annotations are found, rather than marking the migration as having run successfully. --- migration_sql.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/migration_sql.go b/migration_sql.go index 6d11338..fc68d08 100644 --- a/migration_sql.go +++ b/migration_sql.go @@ -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 }