-- 投影以源快照重算,精确版本确认由持久队列承担 alter table request_analytics_facts drop column source_version; -- 制品读取统一使用元数据版本,平台表继续约束同版本同平台的包身份 alter table plugin_artifacts add constraint plugin_artifacts_metadata_version_ck check ( metadata_json ? 'version' and jsonb_typeof(metadata_json->'version') = 'string' and length(metadata_json->>'version') between 1 and 128 ), drop column version; -- 费用事件按请求去重、按 Key 和完成时间重算,复合索引覆盖现行读取 drop index client_api_key_charge_events_client_api_key_id; -- 删除制品时按摘要级联清理所有实例的历史配置 create index plugin_version_configurations_artifact_sha256_idx on plugin_version_configurations (artifact_sha256);