diff --git a/yunke-server/app/storage/repos.py b/yunke-server/app/storage/repos.py index c82c18d..61f4d06 100644 --- a/yunke-server/app/storage/repos.py +++ b/yunke-server/app/storage/repos.py @@ -803,8 +803,13 @@ async def upsert_media( dialect = await _dialect_name(session) pk_cols = _pk_col_names(Media) + # 只更新实际插入的列(2026-09-10 生产修复):此前取全部表列,server_default + # 列(fetched_at/updated_at)不在 values 里 → MySQL 编译出 + # ``new.fetched_at`` 悬空引用 → 每夜 call_recordings 步骤 1054 静默 + # 失败,录音本地化停更多日。 update_cols = [ - c.name for c in Media.__table__.columns if c.name not in pk_cols + c.name for c in Media.__table__.columns + if c.name not in pk_cols and c.name in values ] media_cols = Media.__table__.c @@ -812,7 +817,8 @@ async def upsert_media( """Map each updated column to its conflict-set expression. Volatile download artifacts use ``COALESCE(incoming, existing)``; every - other column is refreshed directly from the incoming row. + other column is refreshed directly from the incoming row. ``updated_at`` + 刷新为 now()(冲突重下时反映最新一次落盘)。 """ set_: dict[str, Any] = {} for name in update_cols: @@ -820,6 +826,7 @@ async def upsert_media( set_[name] = sa.func.coalesce(other_cols[name], media_cols[name]) else: set_[name] = other_cols[name] + set_["updated_at"] = sa.func.now() return set_ if dialect == "sqlite":