feat: 云厂商SDK适配层(Vultr/DO/Cloudflare/阿里云/腾讯云)+ 同步服务 + 测试连接/同步接口与前端
This commit is contained in:
@@ -47,6 +47,19 @@ def init_db() -> None:
|
||||
SQLModel.metadata.create_all(
|
||||
metrics_engine, tables=[m.__table__ for m in metric_models]
|
||||
)
|
||||
_migrate_assets_db()
|
||||
|
||||
|
||||
def _migrate_assets_db() -> None:
|
||||
"""轻量迁移:为已有 assets 表补充新增列(SQLite create_all 不会修改已有表结构)"""
|
||||
import sqlalchemy as sa
|
||||
|
||||
with assets_engine.begin() as conn:
|
||||
if not sa.inspect(conn).has_table("assets"):
|
||||
return
|
||||
cols = {c["name"] for c in sa.inspect(conn).get_columns("assets")}
|
||||
if "external_id" not in cols:
|
||||
conn.execute(sa.text("ALTER TABLE assets ADD COLUMN external_id VARCHAR"))
|
||||
|
||||
|
||||
def get_session() -> Generator[Session, None, None]:
|
||||
|
||||
Reference in New Issue
Block a user