-- 将新的 ODS 任务注册到 etl_admin.etl_task（按需替换 store_id）。
-- 使用方式（示例）：
--   psql "$PG_DSN" -f etl_billiards/database/seed_ods_tasks.sql
-- 或在 psql 中直接执行本文件内容。

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',
        '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',
        'ODS_SETTLEMENT_TICKET'
    ]) AS task_code
)
INSERT INTO etl_admin.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;
