Skip to content

Commit

Permalink
Fix migration logging (#1620)
Browse files Browse the repository at this point in the history
  • Loading branch information
seeker25 authored Jul 16, 2024
1 parent b16ee7c commit 3a5557f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pay-api/src/pay_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ def create_app(run_mode=os.getenv('DEPLOYMENT_ENV', 'production')):
Migrate(app, db)
app.logger.info('Running migration upgrade.')
with app.app_context():
upgrade(directory='migrations', revision='head', sql=False, tag=None)
execute_migrations(app)

# Alembic has it's own logging config, we'll need to restore our logging here.
setup_logging(os.path.join(_Config.PROJECT_ROOT, 'logging.conf'))
app.logger.info('Finished migration upgrade.')
Expand Down Expand Up @@ -96,6 +97,15 @@ def add_version(response): # pylint: disable=unused-variable
return app


def execute_migrations(app):
"""Execute the database migrations."""
try:
upgrade(directory='migrations', revision='head', sql=False, tag=None)
except Exception as e: # NOQA pylint: disable=broad-except
app.logger.error('Error processing migrations:', exc_info=True)
raise e


def setup_jwt_manager(app, jwt_manager):
"""Use flask app to configure the JWTManager to work for a particular Realm."""
def get_roles(a_dict):
Expand Down

0 comments on commit 3a5557f

Please sign in to comment.