You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
使用虚拟环境: F:\nb_fishing_fix\.venv\Scripts\python.exe
04-21 00:30:59 [SUCCESS] nonebot | NoneBot is initializing...
04-21 00:30:59 [INFO] nonebot | Current Env: prod
04-21 00:31:01 [SUCCESS] nonebot | Succeeded to load plugin "nonebot_plugin_localstore"
04-21 00:31:01 [SUCCESS] nonebot | Succeeded to load plugin "nonebot_plugin_orm"
04-21 00:31:01 [SUCCESS] nonebot | Succeeded to load plugin "nonebot_plugin_fishing"
04-21 00:31:01 [SUCCESS] nonebot | Running NoneBot...
04-21 00:31:01 [INFO] uvicorn | Started server process [17068]
04-21 00:31:01 [INFO] uvicorn | Waiting for application startup.
04-21 00:31:01 [ERROR] uvicorn | Traceback (most recent call last):
File "F:\nb_fishing_fix\.venv\lib\site-packages\alembic\script\base.py", line 251, in _catch_revision_errors
yield
File "F:\nb_fishing_fix\.venv\lib\site-packages\alembic\script\base.py", line 314, in get_revisions
self.revision_map.get_revisions(id_),
File "F:\nb_fishing_fix\.venv\lib\site-packages\alembic\script\revision.py", line 543, in get_revisions
return sum([self.get_revisions(id_elem) forid_eleminid_], ())
File "F:\nb_fishing_fix\.venv\lib\site-packages\alembic\script\revision.py", line 543, in<listcomp>return sum([self.get_revisions(id_elem) forid_eleminid_], ())
File "F:\nb_fishing_fix\.venv\lib\site-packages\alembic\script\revision.py", line 566, in get_revisions
return tuple(
File "F:\nb_fishing_fix\.venv\lib\site-packages\alembic\script\revision.py", line 567, in<genexpr>
self._revision_for_ident(rev_id, branch_label)
File "F:\nb_fishing_fix\.venv\lib\site-packages\alembic\script\revision.py", line 638, in _revision_for_ident
raise ResolutionError(
alembic.script.revision.ResolutionError: No such revision or branch '46327b837dd8'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "F:\nb_fishing_fix\.venv\lib\site-packages\starlette\routing.py", line 732, in lifespan
async with self.lifespan_context(app) as maybe_state:
File "D:\Python 3.10.9\lib\contextlib.py", line 199, in __aenter__
return await anext(self.gen)
File "F:\nb_fishing_fix\.venv\lib\site-packages\nonebot\drivers\fastapi.py", line 153, in _lifespan_manager
await self._lifespan.startup()
File "F:\nb_fishing_fix\.venv\lib\site-packages\nonebot\internal\driver\_lifespan.py", line 41, in startup
await self._run_lifespan_func(self._startup_funcs)
File "F:\nb_fishing_fix\.venv\lib\site-packages\nonebot\internal\driver\_lifespan.py", line 35, in _run_lifespan_func
await cast(ASYNC_LIFESPAN_FUNC, func)()
File "F:\nb_fishing_fix\.venv\lib\site-packages\nonebot_plugin_orm\__init__.py", line 84, in init_orm
await greenlet_spawn(migrate.check, alembic_config)
File "F:\nb_fishing_fix\.venv\lib\site-packages\sqlalchemy\util\_concurrency_py3k.py", line 201, in greenlet_spawn
result = context.throw(*sys.exc_info())
File "F:\nb_fishing_fix\.venv\lib\site-packages\nonebot_plugin_orm\migrate.py", line 540, in check
script.run_env()
File "F:\nb_fishing_fix\.venv\lib\site-packages\alembic\script\base.py", line 583, in run_env
util.load_python_file(self.dir, "env.py")
File "F:\nb_fishing_fix\.venv\lib\site-packages\alembic\util\pyfiles.py", line 95, in load_python_file
module = load_module_py(module_id, path)
File "F:\nb_fishing_fix\.venv\lib\site-packages\alembic\util\pyfiles.py", line 113, in load_module_py
spec.loader.exec_module(module) # type: ignore
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "F:\nb_fishing_fix\.venv\lib\site-packages\nonebot_plugin_orm\templates\generic\env.py", line 90, in<module>
await_only(coro)
File "F:\nb_fishing_fix\.venv\lib\site-packages\sqlalchemy\util\_concurrency_py3k.py", line 131, in await_only
return current.driver.switch(awaitable) # type: ignore[no-any-return]
File "F:\nb_fishing_fix\.venv\lib\site-packages\sqlalchemy\util\_concurrency_py3k.py", line 196, in greenlet_spawn
value = await result
File "F:\nb_fishing_fix\.venv\lib\site-packages\nonebot_plugin_orm\templates\generic\env.py", line 79, in run_migrations_online
await connection.run_sync(do_run_migrations)
File "F:\nb_fishing_fix\.venv\lib\site-packages\sqlalchemy\ext\asyncio\engine.py", line 886, in run_sync
return await greenlet_spawn(
File "F:\nb_fishing_fix\.venv\lib\site-packages\sqlalchemy\util\_concurrency_py3k.py", line 203, in greenlet_spawn
result = context.switch(value)
File "F:\nb_fishing_fix\.venv\lib\site-packages\nonebot_plugin_orm\templates\generic\env.py", line 69, in do_run_migrations
context.run_migrations()
File "<string>", line 8, in run_migrations
File "F:\nb_fishing_fix\.venv\lib\site-packages\alembic\runtime\environment.py", line 948, in run_migrations
self.get_context().run_migrations(**kw)
File "F:\nb_fishing_fix\.venv\lib\site-packages\alembic\runtime\migration.py", line 615, in run_migrations
forstepin self._migrations_fn(heads, self):
File "F:\nb_fishing_fix\.venv\lib\site-packages\nonebot_plugin_orm\migrate.py", line 525, in retrieve_migrations
if set(script.get_revisions(rev)) != set(script.get_revisions("heads")):
File "F:\nb_fishing_fix\.venv\lib\site-packages\alembic\script\base.py", line 311, in get_revisions
with self._catch_revision_errors():
File "D:\Python 3.10.9\lib\contextlib.py", line 153, in __exit__
self.gen.throw(typ, value, traceback)
File "F:\nb_fishing_fix\.venv\lib\site-packages\alembic\script\base.py", line 283, in _catch_revision_errors
raise util.CommandError(resolution) from re
alembic.util.exc.CommandError: Can't locate revision identified by '46327b837dd8'
The text was updated successfully, but these errors were encountered:
Linux 环境下的数据库一般为 ~/.local/share/nonebot2/nonebot-plugin-orm/migrations 和 ~/.local/share/nonebot2/nonebot-plugin-orm/db.sqlite3,可删除后,安装 0.2.3 版本,执行 nb orm upgrade。
描述
首次安装该插件,
nb orm upgrade
或nb run
均报错No such revision or branch 'xxxxxxxxxxxxxx'
(报错全部内容详见本层末)
环境
插件版本:0.2.0及以上(使用orm插件后)
Windows 10,Python 3.10.9, nonebot cli version 1.0.5,Nonebot(FastAPI)
复现
nonebot_plugin_orm
并含有migrations文件夹的插件(如nonebot_plugin_skland_arksign
)nb orm upgrade
或nb run
都会导致No such revision or branch 'XXXXXXX'
分析
主观推测是其他插件在表
alembic_version
中存入了一些迁移版本,本插件读取表后进行upgrade,发现本插件下没有对应的迁移分支,故报错解决
(临时解决方案)
sqlite3
->.open db.sqlite3
->SELECT * FROM alembic_version;
nb orm upgrade
和nb run
没有看代码,像是读取了alembic_version表全部的分支然后进行了数据库迁移,不知有没有办法区分alembic_version表下每一项属于哪个插件,或者单独开表?
(真没细看,错了请轻喷XD)
错误报告
The text was updated successfully, but these errors were encountered: