-- Migration: SC-009 — Common Invite enums (access keys + template keys)
-- Description: Enum values for the program-level Common-Invite communication (email + WhatsApp).
--              Common Invite notifies the staff who were issued a generated common Zoom link
--              (zoom_generated_registrant_link, source_type = ROLE) of the shared join link,
--              meeting id and passcode.
--              Kept in its own file so the values are committed before the seed
--              (32_common-invite-template-seed.sql) uses them — Postgres does not allow a
--              newly ADDed enum value to be used in the same transaction.
-- Idempotent — safe to re-run.

-- ------------------------------------------------
-- communication_template_access_key_enum — the send-time access keys
-- ------------------------------------------------
ALTER TYPE communication_template_access_key_enum ADD VALUE IF NOT EXISTS 'COMMON_INVITE_EMAIL_SEEKER';
ALTER TYPE communication_template_access_key_enum ADD VALUE IF NOT EXISTS 'COMMON_INVITE_WATI_SEEKER';

-- ------------------------------------------------
-- template_key_enum — the master/clone template keys seeded in file 32 (PT_TAT)
-- ------------------------------------------------
ALTER TYPE template_key_enum ADD VALUE IF NOT EXISTS 'TAT_COMMON_INVITE_EMAIL_SEEKER';
ALTER TYPE template_key_enum ADD VALUE IF NOT EXISTS 'TAT_COMMON_INVITE_WATI_SEEKER';

-- ------------------------------------------------
-- Verification
-- ------------------------------------------------
SELECT enumlabel
FROM pg_enum e
JOIN pg_type t ON t.oid = e.enumtypid
WHERE t.typname = 'communication_template_access_key_enum'
  AND e.enumlabel IN ('COMMON_INVITE_EMAIL_SEEKER', 'COMMON_INVITE_WATI_SEEKER')
ORDER BY enumlabel;

SELECT enumlabel
FROM pg_enum e
JOIN pg_type t ON t.oid = e.enumtypid
WHERE t.typname = 'template_key_enum'
  AND e.enumlabel IN ('TAT_COMMON_INVITE_EMAIL_SEEKER', 'TAT_COMMON_INVITE_WATI_SEEKER')
ORDER BY enumlabel;
