Merge "db: Don't rely on branched connections"

This commit is contained in:
Zuul 2023-06-07 16:54:01 +00:00 committed by Gerrit Code Review
commit c472d829fa
2 changed files with 22 additions and 10 deletions

View File

@ -95,13 +95,19 @@ def run_migrations_online():
prefix="sqlalchemy.",
poolclass=pool.NullPool,
)
with connectable.connect() as connection:
context.configure(
connection=connection,
target_metadata=target_metadata,
render_as_batch=True,
include_name=include_name,
)
# when connectable is already a Connection object, calling connect() gives
# us a *branched connection*.
with connectable.connect() as connection:
with context.begin_transaction():
context.run_migrations()
else:
context.configure(
connection=connection,
connection=connectable,
target_metadata=target_metadata,
render_as_batch=True,
include_name=include_name,

View File

@ -101,13 +101,19 @@ def run_migrations_online():
prefix="sqlalchemy.",
poolclass=pool.NullPool,
)
with connectable.connect() as connection:
context.configure(
connection=connection,
target_metadata=target_metadata,
render_as_batch=True,
include_name=include_name,
)
# when connectable is already a Connection object, calling connect() gives
# us a *branched connection*.
with connectable.connect() as connection:
with context.begin_transaction():
context.run_migrations()
else:
context.configure(
connection=connection,
connection=connectable,
target_metadata=target_metadata,
render_as_batch=True,
include_name=include_name,