correctly handle when the desiredSchemaVersion < schemaVersion
This commit is contained in:
@ -60,8 +60,13 @@ def init_app(app):
|
||||
|
||||
cursor.execute("SELECT Version FROM schemaversion")
|
||||
schemaVersion = cursor.fetchall()[0][0]
|
||||
|
||||
# print(schemaVersion)
|
||||
|
||||
if schemaVersion > desiredSchemaVersion:
|
||||
print("schemaVersion ({}) > desiredSchemaVersion ({}). schema downgrades are not supported yet. exiting.".format(
|
||||
schemaVersion, desiredSchemaVersion
|
||||
))
|
||||
exit(1)
|
||||
|
||||
while schemaVersion < desiredSchemaVersion:
|
||||
migrationKey = "%02d_up" % (schemaVersion+1)
|
||||
print("schemaVersion ({}) < desiredSchemaVersion ({}). running migration {}".format(
|
||||
@ -94,8 +99,8 @@ def init_app(app):
|
||||
|
||||
app.config['PSYCOPG2_CONNECTION_POOL'].putconn(db)
|
||||
|
||||
print("schema migration completed. {}current schemaVersion: \"{}\"".format(
|
||||
("" if actionWasTaken else "(no action was taken). "), schemaVersion
|
||||
print("{} current schemaVersion: \"{}\"".format(
|
||||
("schema migration completed." if actionWasTaken else "schema is already up to date. "), schemaVersion
|
||||
))
|
||||
|
||||
app.teardown_appcontext(close_db)
|
||||
|
Reference in New Issue
Block a user