Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
f5943a69f0 |
@@ -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"
|
||||
|
@@ -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)
|
||||
|
||||
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."
|
||||
|
||||
if args["up"]:
|
||||
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."
|
||||
|
Reference in New Issue
Block a user