mirror of
https://github.com/insistence/RuoYi-Vue3-FastAPI.git
synced 2026-10-15 05:19:14 +00:00
* feat: 支持 v2 插件、原生扩展与签名发布 * fix: 修复测试 * feat: 增强宿主 SDK、运行观测与制品维护能力 * feat: 增强文件传输、配置观测与本地开发能力 * feat: 支持 SSE 实时事件流并完善开发脚手架 * feat: 完善长连接鉴权复核与关闭回收 * feat: 增强生命周期与任务关闭可靠性 * feat: 收紧健康检查契约并补齐前端与真实网络验收 * feat: 增加SDK溯源与离线更新工具并验证跨版本兼容 * feat: 增加持久化业务示例与受控 Python 交付 * feat: 增加统一运行诊断与多worker状态观测 * feat: 增加固定目标发布等待与自动验收 * fix: 修复多环境插件部署前缀与代理配置不一致 * fix: 修复测试
33 lines
1.4 KiB
Python
33 lines
1.4 KiB
Python
from typing import Literal
|
|
|
|
from config.database import Base, DataSourceRegistry
|
|
from utils.log_util import logger
|
|
|
|
|
|
async def init_create_table(
|
|
*,
|
|
stage: Literal['platform', 'plugin_entities'] = 'platform',
|
|
log_success_enabled: bool = True,
|
|
) -> None:
|
|
"""
|
|
在默认数据源中初始化平台数据库元数据
|
|
|
|
:param stage: 建表阶段
|
|
:param log_success_enabled: 是否输出阶段成功摘要
|
|
:return: None
|
|
"""
|
|
if log_success_enabled:
|
|
message = '🔎 初始化平台数据库元数据...' if stage == 'platform' else '🔎 同步插件实体表...'
|
|
logger.bind(database_init_stage=stage).info(message)
|
|
async with DataSourceRegistry.connection() as connection:
|
|
# 签名制品的数据结构只能由维护迁移准备,普通 worker 不隐式补建其表。
|
|
artifact_tables = [table for table in Base.metadata.tables.values() if table.info.get('plugin_artifact')]
|
|
if artifact_tables:
|
|
tables = [table for table in Base.metadata.tables.values() if not table.info.get('plugin_artifact')]
|
|
await connection.run_sync(Base.metadata.create_all, tables=tables)
|
|
else:
|
|
await connection.run_sync(Base.metadata.create_all)
|
|
if log_success_enabled:
|
|
message = '✅️ 平台数据库元数据初始化完成' if stage == 'platform' else '✅️ 插件实体表同步完成'
|
|
logger.bind(database_init_stage=stage).info(message)
|