diff --git a/nova/db/api/migrations/env.py b/nova/db/api/migrations/env.py index a74e135b2629..770d958647e6 100644 --- a/nova/db/api/migrations/env.py +++ b/nova/db/api/migrations/env.py @@ -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, diff --git a/nova/db/main/migrations/env.py b/nova/db/main/migrations/env.py index 1f593aa561d2..3a872713c2ad 100644 --- a/nova/db/main/migrations/env.py +++ b/nova/db/main/migrations/env.py @@ -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,