Skip to content

Commit 5907585

Browse files
committed
🐛 fix(alembic): env.py open multi transcations
1 parent 334552c commit 5907585

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

nonebot_plugin_orm/templates/generic/env.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ async def run_migrations_online() -> None:
5959
6060
这种情况下,我们需要为 context 创建一个连接。
6161
"""
62-
async with engine.begin() as connection:
62+
async with engine.connect() as connection:
6363
await connection.run_sync(do_run_migrations)
6464

6565

nonebot_plugin_orm/templates/multidb/env.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def run_migrations_offline() -> None:
5252
# 使用 --sql 选项的情况下,将每个引擎的迁移写入到单独的 .sql 文件中。
5353

5454
for name, engine in engines.items():
55+
config.print_stdout(f"迁移数据库 {name or '<default>'} 中 ...")
5556
file_ = f"{name}.sql"
5657
with open(file_, "w") as buffer:
5758
context.configure(
@@ -62,9 +63,7 @@ def run_migrations_offline() -> None:
6263
dialect_opts={"paramstyle": "named"},
6364
**plugin_config.alembic_context,
6465
)
65-
with context.begin_transaction(), config.status(
66-
f"迁移数据库 {name or '<default>'} 中"
67-
):
66+
with context.begin_transaction():
6867
context.run_migrations(name=name)
6968
config.print_stdout(f"将输出写入到 {file_}")
7069

0 commit comments

Comments
 (0)