-- Migration: SC-015 — System Links (PER-SESSION) enums (access key + template key)
-- Description: Enum values for the per-session variant of the System-Links communication
--              (email only, to the program's ADMIN users). Same audience + HTML link table as
--              the program-level System Links (36_system-links-template-seed.sql), but scoped to
--              ONE session — used when the program's links are generated per session
--              (SessionLinkModeEnum.PER_SESSION) so the message carries that session's
--              name / date / time.
--              Kept in its own file so the values are committed before the seed
--              (45_system-links-per-session-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_PER_SESSION_EMAIL_ADMIN';

-- ------------------------------------------------
-- template_key_enum — the master/clone template key seeded in file 45 (PT_TAT)
-- ------------------------------------------------
ALTER TYPE template_key_enum ADD VALUE IF NOT EXISTS 'TAT_SYSTEM_LINKS_PER_SESSION_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_PER_SESSION_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_PER_SESSION_EMAIL_ADMIN';
