diff --git a/db_migrate.nimble b/db_migrate.nimble index e2b3b4c..9119dfa 100644 --- a/db_migrate.nimble +++ b/db_migrate.nimble @@ -1,7 +1,7 @@ # Package bin = @["db_migrate"] -version = "0.3.2" +version = "0.4.0" author = "Jonathan Bernard" description = "Simple tool to handle database migrations." license = "BSD" diff --git a/src/main/nim/db_migrate.nim b/src/main/nim/db_migrate.nim index 8449dfe..06f19ea 100644 --- a/src/main/nim/db_migrate.nim +++ b/src/main/nim/db_migrate.nim @@ -249,7 +249,7 @@ Options: """ # Parse arguments - let args = docopt(doc, version = "db-migrate (Nim) 0.3.2\nhttps://git.jdb-software.com/jdb/db-migrate") + let args = docopt(doc, version = "db-migrate (Nim) 0.4.0\nhttps://git.jdb-software.com/jdb/db-migrate") let exitErr = proc(msg: string): void = fatal("db_migrate: " & msg) @@ -307,12 +307,12 @@ Options: let (available, run, notRun, missing) = diffMigrations(pgConn, config) - # Make sure we have no gaps (database is in an unknown state) - if missing.len > 0: - exitErr "Database is in an inconsistent state. Migrations have been " & - "run that are not sequential." - if args["up"]: + # Make sure we have no gaps (database is in an unknown state) + if missing.len > 0: + exitErr "Database is in an inconsistent state. Migrations have been " & + "run that are not sequential." + try: let count = if args[""]: parseInt($args[""]) else: high(int) let toRun = if count < notRun.len: notRun[0.. 0: + exitErr "Database is in an inconsistent state. Migrations have been " & + "run that are not sequential." + if newResults.notRun.len > 0: info "Database is behind by " & $(newResults.notRun.len) & " migrations." else: info "Database is up to date."