-- Add should_send_terms flag to program_type, program, and program_session tables
-- Controls whether T&C PDF is attached to registration confirmation emails
-- Resolution priority: session -> program -> program_type -> false (default)

ALTER TABLE program_type_v1
  ADD COLUMN IF NOT EXISTS should_send_terms BOOLEAN NOT NULL DEFAULT FALSE;

ALTER TABLE program_v1
  ADD COLUMN IF NOT EXISTS should_send_terms BOOLEAN NOT NULL DEFAULT FALSE;

ALTER TABLE program_session
  ADD COLUMN IF NOT EXISTS should_send_terms BOOLEAN NOT NULL DEFAULT FALSE;


-- Widen hdb_question.label from varchar(1024) to text
ALTER TABLE hdb_question ALTER COLUMN label TYPE text;

--- Set should_send_terms to true for PT_TAT program type
update program_type_v1
set should_send_terms = true
where key = 'PT_TAT';

