forked from 3wordchant/capsul-flask
more managed ips work: cli sql improvements, added admin panel
This commit is contained in:
@ -10,7 +10,7 @@ from flask import g
|
||||
from capsulflask.db_model import DBModel
|
||||
from capsulflask.shared import my_exec_info_message
|
||||
|
||||
def init_app(app):
|
||||
def init_app(app, is_running_server):
|
||||
|
||||
app.config['PSYCOPG2_CONNECTION_POOL'] = psycopg2.pool.SimpleConnectionPool(
|
||||
1,
|
||||
@ -18,6 +18,14 @@ def init_app(app):
|
||||
app.config['POSTGRES_CONNECTION_PARAMETERS']
|
||||
)
|
||||
|
||||
# tell the app to clean up the DB connection when shutting down.
|
||||
app.teardown_appcontext(close_db)
|
||||
|
||||
# only run the migrations if we are running the server.
|
||||
# If we are just running a cli command (e.g. to fix a broken migration 😅), skip it
|
||||
if not is_running_server:
|
||||
return
|
||||
|
||||
schemaMigrations = {}
|
||||
schemaMigrationsPath = join(app.root_path, 'schema_migrations')
|
||||
app.logger.info("loading schema migration scripts from {}".format(schemaMigrationsPath))
|
||||
@ -35,7 +43,7 @@ def init_app(app):
|
||||
hasSchemaVersionTable = False
|
||||
actionWasTaken = False
|
||||
schemaVersion = 0
|
||||
desiredSchemaVersion = 15
|
||||
desiredSchemaVersion = 16
|
||||
|
||||
cursor = connection.cursor()
|
||||
|
||||
@ -103,7 +111,7 @@ def init_app(app):
|
||||
("schema migration completed." if actionWasTaken else "schema is already up to date. "), schemaVersion
|
||||
))
|
||||
|
||||
app.teardown_appcontext(close_db)
|
||||
|
||||
|
||||
|
||||
def get_model():
|
||||
|
Reference in New Issue
Block a user