-- Migration: SC-013 — System Links enums (access key + template key)
-- Description: Enum values for the program-level System-Links communication (email only, to ADMIN
--              users). It lists the generated system/placeholder Zoom links
--              (zoom_generated_registrant_link, source_type = PLACEHOLDER) as a table.
--              Kept in its own file so the values are committed before the seed
--              (36_system-links-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 key
-- ------------------------------------------------
ALTER TYPE communication_template_access_key_enum ADD VALUE IF NOT EXISTS 'SYSTEM_LINKS_EMAIL_ADMIN';

-- ------------------------------------------------
-- template_key_enum — the master/clone template key seeded in file 36 (PT_TAT)
-- ------------------------------------------------
ALTER TYPE template_key_enum ADD VALUE IF NOT EXISTS 'TAT_SYSTEM_LINKS_EMAIL_ADMIN';

-- ------------------------------------------------
-- 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 = 'SYSTEM_LINKS_EMAIL_ADMIN';

SELECT enumlabel
FROM pg_enum e
JOIN pg_type t ON t.oid = e.enumtypid
WHERE t.typname = 'template_key_enum'
  AND e.enumlabel = 'TAT_SYSTEM_LINKS_EMAIL_ADMIN';
