|
|
|
@@ -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["<count>"]: parseInt($args["<count>"]) else: high(int)
|
|
|
|
|
let toRun = if count < notRun.len: notRun[0..<count] else: notRun
|
|
|
|
@@ -334,6 +334,11 @@ Options:
|
|
|
|
|
elif args["init"]: discard
|
|
|
|
|
|
|
|
|
|
let newResults = diffMigrations(pgConn, config)
|
|
|
|
|
|
|
|
|
|
if newResults.missing.len > 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."
|
|
|
|
|