-- 067_data_retention_indexes.sql —— 数据保留清理所需索引。

CREATE INDEX IF NOT EXISTS idx_webhook_events_created_at
  ON webhook_events(created_at DESC);

CREATE INDEX IF NOT EXISTS idx_orders_updated_at
  ON orders(updated_at DESC);

CREATE INDEX IF NOT EXISTS idx_kuaishou_industry_vouchers_updated_at
  ON kuaishou_industry_vouchers(updated_at DESC);

CREATE INDEX IF NOT EXISTS idx_task_events_created_at
  ON task_events(created_at DESC);

DROP INDEX IF EXISTS idx_work_product_match_logs_created_at;

COMMENT ON INDEX idx_webhook_events_created_at IS '支持 webhook 回调去重数据按创建时间清理';
COMMENT ON INDEX idx_orders_updated_at IS '支持订单原始报文按更新时间清理';
COMMENT ON INDEX idx_kuaishou_industry_vouchers_updated_at IS '支持电子凭证原始报文按更新时间清理';
COMMENT ON INDEX idx_task_events_created_at IS '支持任务事件按创建时间清理';
