-- 将新的 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[
        'ODS_ASSISTANT_ACCOUNTS',
        'ODS_ASSISTANT_LEDGER',
        'ODS_ASSISTANT_ABOLISH',
        'ODS_INVENTORY_CHANGE',
        'ODS_INVENTORY_STOCK',
        'ODS_PACKAGE',
        'ODS_GROUP_BUY_REDEMPTION',
        'ODS_MEMBER',
        'ODS_MEMBER_BALANCE',
        'ODS_MEMBER_CARD',
        'ODS_PAYMENT',
        'ODS_REFUND',
        'ODS_COUPON_VERIFY',
        'ODS_RECHARGE_SETTLE',
        'ODS_TABLES',
        'ODS_GOODS_CATEGORY',
        'ODS_STORE_GOODS',
        'ODS_TABLE_DISCOUNT',
        'ODS_TENANT_GOODS',
        'ODS_SETTLEMENT_TICKET',
        'ODS_ORDER_SETTLE'
    ]) 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;

