-- CHANGE 2026-02-15 | 修复 schema 引用：etl_admin → meta（对齐新库 etl_feiqiu 六层架构）
-- 将新的 ODS 任务注册到 meta.etl_task（按需替换 store_id）。

WITH target_store AS (
    SELECT 2790685415443269::bigint AS store_id  -- TODO: 替换为实际 store_id
),
task_codes AS (
    SELECT unnest(ARRAY[
        -- Must match tasks/ods_tasks.py (ENABLED_ODS_CODES)
        'ODS_ASSISTANT_ACCOUNT',
        'ODS_ASSISTANT_LEDGER',
        -- CHANGE [2026-02-24] intent: 移除 ODS_ASSISTANT_ABOLISH（全链路已清理，表已删除）
        'ODS_SETTLEMENT_RECORDS',
        'ODS_TABLE_USE',
        'ODS_PAYMENT',
        'ODS_REFUND',
        'ODS_PLATFORM_COUPON',
        'ODS_MEMBER',
        'ODS_MEMBER_CARD',
        'ODS_MEMBER_BALANCE',
        'ODS_RECHARGE_SETTLE',
        'ODS_GROUP_PACKAGE',
        'ODS_GROUP_BUY_REDEMPTION',
        'ODS_INVENTORY_STOCK',
        'ODS_INVENTORY_CHANGE',
        'ODS_TABLES',
        'ODS_GOODS_CATEGORY',
        'ODS_STORE_GOODS',
        'ODS_STORE_GOODS_SALES',
        'ODS_TABLE_FEE_DISCOUNT',
        'ODS_TENANT_GOODS'
    ]) AS task_code
)
INSERT INTO meta.etl_task (task_code, store_id, enabled)
SELECT t.task_code, s.store_id, TRUE
FROM task_codes t CROSS JOIN target_store s
ON CONFLICT (task_code, store_id) DO UPDATE
SET enabled = EXCLUDED.enabled;
