🐛 fix(env.py): enable batch rendering for migrations to improve performance

This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-08-27 19:55:32 -03:00
commit d06ea50674

View file

@ -46,6 +46,7 @@ def run_migrations_offline() -> None:
target_metadata=target_metadata,
literal_binds=True,
dialect_opts={"paramstyle": "named"},
render_as_batch=True,
)
with context.begin_transaction():
@ -66,7 +67,9 @@ def run_migrations_online() -> None:
)
with connectable.connect() as connection:
context.configure(connection=connection, target_metadata=target_metadata)
context.configure(
connection=connection, target_metadata=target_metadata, render_as_batch=True
)
with context.begin_transaction():
context.run_migrations()