Skip to content

Commit 4a7dda3

Browse files
committed
🐛 fix(alembic): no cmd opts when startup
1 parent b0ff2a4 commit 4a7dda3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

nonebot_plugin_orm/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import logging
55
from typing import Any
66
from asyncio import gather
7+
from argparse import Namespace
78
from operator import methodcaller
89
from collections.abc import AsyncGenerator
910
from functools import wraps, partial, lru_cache
@@ -74,15 +75,20 @@
7475
async def init_orm() -> None:
7576
_init_orm()
7677

77-
with migrate.AlembicConfig(stdout=StreamToLogger()) as alembic_config:
78+
cmd_opts = Namespace()
79+
with migrate.AlembicConfig(
80+
stdout=StreamToLogger(), cmd_opts=cmd_opts
81+
) as alembic_config:
7882
if plugin_config.alembic_startup_check:
83+
cmd_opts.cmd = (migrate.check, [], [])
7984
try:
8085
await greenlet_spawn(migrate.check, alembic_config)
8186
except click.UsageError:
8287
logger.error("启动检查失败")
8388
raise
8489
else:
8590
logger.warning("跳过启动检查, 正在同步数据库模式...")
91+
cmd_opts.cmd = (migrate.sync, ["revision"], [])
8692
await greenlet_spawn(migrate.sync, alembic_config)
8793

8894

0 commit comments

Comments
 (0)