From 4e7db61ab232d657645041ab30161d9a0201e3e3 Mon Sep 17 00:00:00 2001 From: Wu Clan Date: Sun, 15 Mar 2026 19:04:40 +0800 Subject: [PATCH] Fix install plugin cli --- backend/cli.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/backend/cli.py b/backend/cli.py index 9d561822..8f09dde7 100644 --- a/backend/cli.py +++ b/backend/cli.py @@ -47,6 +47,7 @@ from backend.plugin.core import build_sql_filename, get_plugin_destroy_sql, get_ from backend.plugin.installer import install_git_plugin, install_zip_plugin, zip_plugin from backend.plugin.installer import remove_plugin as _remove_plugin from backend.plugin.requirements import uninstall_requirements_async +from backend.utils.dynamic_import import import_module_cached from backend.utils.console import console from backend.utils.sql_parser import parse_sql_script from backend.utils.timezone import timezone @@ -372,6 +373,16 @@ async def install_plugin( console.tip(f'插件 {plugin_name} 安装成功') + console.note(f'正在同步插件 {plugin_name} 数据库表...') + try: + import_module_cached(f'backend.plugin.{plugin_name}.model') + except ModuleNotFoundError: + pass + else: + async with async_db_session.begin() as db: + conn = await db.connection() + await conn.run_sync(MappedBase.metadata.create_all) + if not no_sql: sql_file = await get_plugin_sql(plugin_name, db_type, pk_type) if sql_file: