Skip to content

Commit

Permalink
chore: Upgrade migrations environment
Browse files Browse the repository at this point in the history
  • Loading branch information
TomBursch committed Dec 26, 2024
1 parent f9336e4 commit d1b6b41
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions backend/migrations/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@


def get_engine():
try:
# this works with Flask-SQLAlchemy<3 and Alchemical
return current_app.extensions['migrate'].db.get_engine()
except TypeError:
# this works with Flask-SQLAlchemy>=3
return current_app.extensions['migrate'].db.engine
return current_app.extensions['migrate'].db.engine


def get_engine_url():
Expand Down Expand Up @@ -90,14 +85,17 @@ def process_revision_directives(context, revision, directives):
directives[:] = []
logger.info('No changes in schema detected.')

conf_args = current_app.extensions['migrate'].configure_args
if conf_args.get("process_revision_directives") is None:
conf_args["process_revision_directives"] = process_revision_directives

connectable = get_engine()

with connectable.connect() as connection:
context.configure(
connection=connection,
target_metadata=get_metadata(),
process_revision_directives=process_revision_directives,
**current_app.extensions['migrate'].configure_args
**conf_args
)

with context.begin_transaction():
Expand Down

0 comments on commit d1b6b41

Please sign in to comment.