-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't locate revision identified by '486a6e0eed5b' #111
Comments
系统是阿里云服务器的Windows Server 2022 Datacenter |
你之前应该装过依赖 plugin-orm 的插件,然后又卸载了,但是 orm 的数据库里仍有记录,所以找不到那个插件的迁移脚本
|
MeetWq
changed the title
更新后运行会报错,AI分析说是在使用 Alembic 进行数据库迁移时遇到的错误
Can't locate revision identified by '486a6e0eed5b'
Aug 26, 2024
谢谢佬,用了方法3,直接搞掂了。虽然代价是隔壁群聊学习插件好像也被波及了。 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
nb run 运行后报错代码如下:
08-26 09:04:43 [ERROR] uvicorn | Traceback (most recent call last):
File "C:\bot\nonebot\bot1.venv\lib\site-packages\alembic\script\base.py", line 250, in catch_revision_errors
yield
File "C:\bot\nonebot\bot1.venv\lib\site-packages\alembic\script\base.py", line 313, in get_revisions
self.revision_map.get_revisions(id),
File "C:\bot\nonebot\bot1.venv\lib\site-packages\alembic\script\revision.py", line 542, in get_revisions
return sum([self.get_revisions(id_elem) for id_elem in id_], ())
File "C:\bot\nonebot\bot1.venv\lib\site-packages\alembic\script\revision.py", line 542, in
return sum([self.get_revisions(id_elem) for id_elem in id_], ())
File "C:\bot\nonebot\bot1.venv\lib\site-packages\alembic\script\revision.py", line 565, in get_revisions
return tuple(
File "C:\bot\nonebot\bot1.venv\lib\site-packages\alembic\script\revision.py", line 566, in
self._revision_for_ident(rev_id, branch_label)
File "C:\bot\nonebot\bot1.venv\lib\site-packages\alembic\script\revision.py", line 637, in _revision_for_ident
raise ResolutionError(
alembic.script.revision.ResolutionError: No such revision or branch '486a6e0eed5b'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\bot\nonebot\bot1.venv\lib\site-packages\starlette\routing.py", line 732, in lifespan
async with self.lifespan_context(app) as maybe_state:
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\contextlib.py", line 199, in aenter
return await anext(self.gen)
File "C:\bot\nonebot\bot1.venv\lib\site-packages\nonebot\drivers\fastapi.py", line 153, in _lifespan_manager
await self._lifespan.startup()
File "C:\bot\nonebot\bot1.venv\lib\site-packages\nonebot\internal\driver_lifespan.py", line 42, in startup
await self._run_lifespan_func(self._startup_funcs)
File "C:\bot\nonebot\bot1.venv\lib\site-packages\nonebot\internal\driver_lifespan.py", line 36, in run_lifespan_func
await cast(ASYNC_LIFESPAN_FUNC, func)()
File "C:\bot\nonebot\bot1.venv\lib\site-packages\nonebot_plugin_orm_init.py", line 84, in init_orm
await greenlet_spawn(migrate.check, alembic_config)
File "C:\bot\nonebot\bot1.venv\lib\site-packages\sqlalchemy\util_concurrency_py3k.py", line 201, in greenlet_spawn
result = context.throw(*sys.exc_info())
File "C:\bot\nonebot\bot1.venv\lib\site-packages\nonebot_plugin_orm\migrate.py", line 556, in check
script.run_env()
File "C:\bot\nonebot\bot1.venv\lib\site-packages\alembic\script\base.py", line 582, in run_env
util.load_python_file(self.dir, "env.py")
File "C:\bot\nonebot\bot1.venv\lib\site-packages\alembic\util\pyfiles.py", line 95, in load_python_file
module = load_module_py(module_id, path)
File "C:\bot\nonebot\bot1.venv\lib\site-packages\alembic\util\pyfiles.py", line 113, in load_module_py
spec.loader.exec_module(module) # type: ignore
File "", line 883, in exec_module
File "", line 241, in _call_with_frames_removed
File "C:\bot\nonebot\bot1.venv\lib\site-packages\nonebot_plugin_orm\templates\generic\env.py", line 90, in
await_only(coro)
File "C:\bot\nonebot\bot1.venv\lib\site-packages\sqlalchemy\util_concurrency_py3k.py", line 132, in await_only
return current.parent.switch(awaitable) # type: ignore[no-any-return,attr-defined] # noqa: E501
File "C:\bot\nonebot\bot1.venv\lib\site-packages\sqlalchemy\util_concurrency_py3k.py", line 196, in greenlet_spawn
value = await result
File "C:\bot\nonebot\bot1.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 "C:\bot\nonebot\bot1.venv\lib\site-packages\sqlalchemy\ext\asyncio\engine.py", line 886, in run_sync
return await greenlet_spawn(
File "C:\bot\nonebot\bot1.venv\lib\site-packages\sqlalchemy\util_concurrency_py3k.py", line 203, in greenlet_spawn
result = context.switch(value)
File "C:\bot\nonebot\bot1.venv\lib\site-packages\nonebot_plugin_orm\templates\generic\env.py", line 69, in do_run_migrations
context.run_migrations()
File "", line 8, in run_migrations
File "C:\bot\nonebot\bot1.venv\lib\site-packages\alembic\runtime\environment.py", line 946, in run_migrations
self.get_context().run_migrations(**kw)
File "C:\bot\nonebot\bot1.venv\lib\site-packages\alembic\runtime\migration.py", line 616, in run_migrations
for step in self._migrations_fn(heads, self):
File "C:\bot\nonebot\bot1.venv\lib\site-packages\nonebot_plugin_orm\migrate.py", line 541, in retrieve_migrations
if set(script.get_revisions(rev)) != set(script.get_revisions("heads")):
File "C:\bot\nonebot\bot1.venv\lib\site-packages\alembic\script\base.py", line 310, in get_revisions
with self._catch_revision_errors():
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\contextlib.py", line 153, in exit
self.gen.throw(typ, value, traceback)
File "C:\bot\nonebot\bot1.venv\lib\site-packages\alembic\script\base.py", line 282, in _catch_revision_errors
raise util.CommandError(resolution) from re
alembic.util.exc.CommandError: Can't locate revision identified by '486a6e0eed5b'
08-26 09:04:43 [ERROR] uvicorn | Application startup failed. Exiting.
然后整个nonebot会停在这。卸载掉本插件后就没有相关报错并正常运行。丢给ai分析说是这段日志显示了在使用 Alembic 进行数据库迁移时遇到的错误。错误的核心是一个 ResolutionError,它表明 Alembic 无法找到指定的修订版本或分支 '486a6e0eed5b'。
但我理论上就执行了一堆的插件更新指令而已。plugin-orm那边更是完全没看懂,但应该没动过?有点懵,不知道该如何处理。
用的nbcil搭的nonebot2,虚拟环境。
The text was updated successfully, but these errors were encountered: