Fix alembic migrations importing app

Ensure we connect to loaded config db
This commit is contained in:
Sam Chow 2018-06-19 13:46:34 -04:00
parent bb2b28cd11
commit b5f630ba29
18 changed files with 69 additions and 81 deletions

View file

@ -22,9 +22,6 @@ logger = logging.getLogger(__name__)
def database_is_valid():
""" Returns whether the database, as configured, is valid. """
if app.config['TESTING']:
return False
return model.is_valid()
@ -103,9 +100,6 @@ class SuperUserConfig(ApiResource):
# Link the existing user to the external user.
model.attach_federated_login(current_user.username, service_name, result.username)
# Ensure database is up-to-date with config
sync_database_with_config(config_object)
return {
'exists': True,
'config': config_object
@ -182,11 +176,12 @@ class SuperUserSetupDatabase(ApiResource):
configure(combined)
app.config['DB_URI'] = combined['DB_URI']
db_uri = app.config['DB_URI']
log_handler = _AlembicLogHandler()
try:
run_alembic_migration(log_handler)
run_alembic_migration(db_uri, log_handler)
except Exception as ex:
return {
'error': str(ex)