在准备环境前提交次全部更改。
This commit is contained in:
@@ -2048,8 +2048,89 @@ COMMENT ON COLUMN ods.store_goods_sales_records.source_endpoint IS '【说明】
|
||||
COMMENT ON COLUMN ods.store_goods_sales_records.fetched_at IS '【说明】ETL 元数据:采集/入库时间戳,用于口径对齐与增量处理。 【示例】2025-11-10T00:00:00+08:00(ETL 元数据:采集/入库时间戳,用于口径对齐与增量处理)。 【JSON字段】store_goods_sales_records.json - ETL元数据 - 无。';
|
||||
|
||||
|
||||
-- ============================================================
|
||||
-- "取最新版本"复合索引
|
||||
-- 支持 DISTINCT ON (pk) ORDER BY pk, fetched_at DESC 查询模式
|
||||
-- 迁移脚本:migrations/2026-02-17__add_ods_latest_version_indexes.sql
|
||||
-- ============================================================
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_ods_member_profiles_latest
|
||||
ON ods.member_profiles (id, fetched_at DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_ods_member_balance_changes_latest
|
||||
ON ods.member_balance_changes (id, fetched_at DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_ods_member_stored_value_cards_latest
|
||||
ON ods.member_stored_value_cards (id, fetched_at DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_ods_recharge_settlements_latest
|
||||
ON ods.recharge_settlements (id, fetched_at DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_ods_settlement_records_latest
|
||||
ON ods.settlement_records (id, fetched_at DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_ods_assistant_cancellation_records_latest
|
||||
ON ods.assistant_cancellation_records (id, fetched_at DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_ods_assistant_accounts_master_latest
|
||||
ON ods.assistant_accounts_master (id, fetched_at DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_ods_assistant_service_records_latest
|
||||
ON ods.assistant_service_records (id, fetched_at DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_ods_site_tables_master_latest
|
||||
ON ods.site_tables_master (id, fetched_at DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_ods_table_fee_discount_records_latest
|
||||
ON ods.table_fee_discount_records (id, fetched_at DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_ods_table_fee_transactions_latest
|
||||
ON ods.table_fee_transactions (id, fetched_at DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_ods_goods_stock_movements_latest
|
||||
ON ods.goods_stock_movements (siteGoodsStockId, fetched_at DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_ods_stock_goods_category_tree_latest
|
||||
ON ods.stock_goods_category_tree (id, fetched_at DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_ods_goods_stock_summary_latest
|
||||
ON ods.goods_stock_summary (siteGoodsId, fetched_at DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_ods_payment_transactions_latest
|
||||
ON ods.payment_transactions (id, fetched_at DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_ods_refund_transactions_latest
|
||||
ON ods.refund_transactions (id, fetched_at DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_ods_platform_coupon_redemption_records_latest
|
||||
ON ods.platform_coupon_redemption_records (id, fetched_at DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_ods_tenant_goods_master_latest
|
||||
ON ods.tenant_goods_master (id, fetched_at DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_ods_group_buy_packages_latest
|
||||
ON ods.group_buy_packages (id, fetched_at DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_ods_group_buy_redemption_records_latest
|
||||
ON ods.group_buy_redemption_records (id, fetched_at DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_ods_settlement_ticket_details_latest
|
||||
ON ods.settlement_ticket_details (orderSettleId, fetched_at DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_ods_store_goods_master_latest
|
||||
ON ods.store_goods_master (id, fetched_at DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_ods_store_goods_sales_records_latest
|
||||
ON ods.store_goods_sales_records (id, fetched_at DESC);
|
||||
|
||||
|
||||
-- AI_CHANGELOG:
|
||||
-- - 日期: 2026-02-17
|
||||
-- - Prompt: ods-dedup-standardize Task 5.1
|
||||
-- - 直接原因: ODS 去重标准化需要 DISTINCT ON (pk) ORDER BY pk, fetched_at DESC 查询模式的索引支持
|
||||
-- - 变更摘要: 为全部 23 张 ODS 表添加 (业务主键, fetched_at DESC) 复合索引定义
|
||||
-- - 风险与验证: DDL 文档性文件,新环境初始化时自动创建索引;已有环境通过迁移脚本部署
|
||||
--
|
||||
-- - 日期: 2026-02-14
|
||||
-- - Prompt: P20260214-070000 — ODS 清理与文档标注(5 项任务)
|
||||
-- - 直接原因: option_name(store_goods_sales_records)和 able_site_transfer(member_stored_value_cards)在 API 中不存在且全 NULL,需从 DDL 中注释化
|
||||
|
||||
Reference in New Issue
Block a user