From d7461ed54c244bafe3f35c99c167cf4965b4a488 Mon Sep 17 00:00:00 2001 From: LIghtJUNction Date: Fri, 31 Oct 2025 23:37:37 +0800 Subject: [PATCH] =?UTF-8?q?fix(helper.py):=20=E4=BF=AE=E5=A4=8D=E4=BA=86?= =?UTF-8?q?=E8=BF=81=E7=A7=BB=E9=80=BB=E8=BE=91=EF=BC=8C=E7=8E=B0=E5=9C=A8?= =?UTF-8?q?=E4=B8=8D=E5=86=8D=E8=AF=AF=E5=88=A4=20(#3215)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(helper.py): 修复了迁移逻辑,现在不再误判 * fix(helper.py): 没有data_v3 dir --- astrbot/core/db/migration/helper.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/astrbot/core/db/migration/helper.py b/astrbot/core/db/migration/helper.py index 901cdc4ed..0b7888548 100644 --- a/astrbot/core/db/migration/helper.py +++ b/astrbot/core/db/migration/helper.py @@ -17,8 +17,11 @@ async def check_migration_needed_v4(db_helper: BaseDatabase) -> bool: 检查是否需要进行数据库迁移 如果存在 data_v3.db 并且 preference 中没有 migration_done_v4,则需要进行迁移。 """ - data_v3_exists = os.path.exists(get_astrbot_data_path()) - if not data_v3_exists: + # 仅当 data 目录下存在旧版本数据(data_v3.db 文件)时才考虑迁移 + data_dir = get_astrbot_data_path() + data_v3_db = os.path.join(data_dir, "data_v3.db") + + if not os.path.exists(data_v3_db): return False migration_done = await db_helper.get_preference( "global", "global", "migration_done_v4" @@ -32,7 +35,7 @@ async def do_migration_v4( db_helper: BaseDatabase, platform_id_map: dict[str, dict[str, str]], astrbot_config: AstrBotConfig, -): +) -> None: """ 执行数据库迁移 迁移旧的 webchat_conversation 表到新的 conversation 表。