-- Seed scheduler-compatible tasks into etl_admin.etl_task.
--
-- Notes:
-- - These task_code values must match orchestration/task_registry.py.
-- - ODS_* tasks are intentionally excluded here because they don't follow the
--   BaseTask(cursor_data) scheduler interface in this repo version.
--
-- Usage (example):
--   psql "%PG_DSN%" -f etl_billiards/database/seed_scheduler_tasks.sql
--
WITH target_store AS (
    SELECT 2790685415443269::bigint AS store_id  -- TODO: replace with your store_id
),
task_codes AS (
    SELECT unnest(ARRAY[
        'ASSISTANT_ABOLISH',
        'ASSISTANTS',
        'COUPON_USAGE',
        'CHECK_CUTOFF',
        'DATA_INTEGRITY_CHECK',
        'DWD_LOAD_FROM_ODS',
        'DWD_QUALITY_CHECK',
        'INIT_DWD_SCHEMA',
        'INIT_DWS_SCHEMA',
        'INIT_ODS_SCHEMA',
        'INVENTORY_CHANGE',
        'LEDGER',
        'MANUAL_INGEST',
        'MEMBERS',
        'MEMBERS_DWD',
        'ODS_JSON_ARCHIVE',
        'ORDERS',
        'PACKAGES_DEF',
        'PAYMENTS',
        'PAYMENTS_DWD',
        'PRODUCTS',
        'REFUNDS',
        'TABLE_DISCOUNT',
        'TABLES',
        'TICKET_DWD',
        'TOPUPS',
        'DWS_BUILD_ORDER_SUMMARY'
    ]) 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,
    updated_at = now();
