feat: 平台同步状态记录(last_synced_at + 前端展示最后同步时间)

This commit is contained in:
gouki
2026-08-02 16:32:36 +00:00
parent cc69927f8c
commit 6109878c7e
5 changed files with 25 additions and 7 deletions
+10 -6
View File
@@ -51,15 +51,19 @@ def init_db() -> None:
def _migrate_assets_db() -> None:
"""轻量迁移:为已有 assets 表补充新增列(SQLite create_all 不会修改已有表结构)"""
"""轻量迁移:为已有表补充新增列(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"))
insp = sa.inspect(conn)
if insp.has_table("assets"):
cols = {c["name"] for c in insp.get_columns("assets")}
if "external_id" not in cols:
conn.execute(sa.text("ALTER TABLE assets ADD COLUMN external_id VARCHAR"))
if insp.has_table("providers"):
cols = {c["name"] for c in insp.get_columns("providers")}
if "last_synced_at" not in cols:
conn.execute(sa.text("ALTER TABLE providers ADD COLUMN last_synced_at DATETIME"))
def get_session() -> Generator[Session, None, None]: