
ALTER TYPE communication_category_enum
ADD VALUE 'online_payment_acknowledgement';

ALTER TYPE communication_template_access_key_enum
ADD VALUE 'ONLINE_PAYMENT_ACKNOWLEDGEMENT_EMAIL_SEEKER';


--- update TAT_ONLINE_PAYMENT_COMPLETION_EMAIL
select * from public.communication_templates_master where template_key = 'TAT_ONLINE_PAYMENT_COMPLETION_EMAIL';
Update public.communication_templates_master
set template_key = 'TAT_OFFLINE_PAYMENT_ACKNOWLEDGEMENT_EMAIL',
template_name = 'TAT Offline Payment Acknowledgement - Email'
where template_key = 'TAT_ONLINE_PAYMENT_COMPLETION_EMAIL';

select * from public.communication_templates_master where template_key = 'TAT_OFFLINE_PAYMENT_ACKNOWLEDGEMENT_EMAIL';

--- update TAT_REGISTRATION_ACKNOWLEDGEMENT_EMAIL
select * from public.communication_templates_master where template_key = 'TAT_REGISTRATION_ACKNOWLEDGEMENT_EMAIL';


Update public.communication_templates_master
set template_key = 'TAT_ONLINE_PAYMENT_ACKNOWLEDGEMENT_EMAIL',
template_name = 'TAT Online Payment Acknowledgement - Email',
category = 'online_payment_acknowledgement',
template_access_key = 'ONLINE_PAYMENT_ACKNOWLEDGEMENT_EMAIL_SEEKER'
where template_key = 'TAT_REGISTRATION_ACKNOWLEDGEMENT_EMAIL' and 
program_type_id in (SELECT id FROM program_type_v1 WHERE key = 'PT_TAT');

select * from public.communication_templates_master where template_key = 'TAT_ONLINE_PAYMENT_ACKNOWLEDGEMENT_EMAIL';


 ---- update formatProgramDateRange with formatSessionDateRange
select * from communication_templates_master where template_key = 'TAT_INVOICE_EMAIL' and 
program_type_id in (SELECT id FROM program_type_v1 WHERE key = 'PT_TAT');

UPDATE communication_templates_master
SET merge_field_map = REPLACE(
    merge_field_map::text,
    'formatProgramDateRange',
    'formatSessionDateRange'
)::jsonb
WHERE template_key = 'TAT_INVOICE_EMAIL' and
program_type_id in (SELECT id FROM program_type_v1 WHERE key = 'PT_TAT');