-- Add merge tracking to contact submissions
ALTER TABLE contact_submissions
ADD COLUMN merged_ticket_numbers text[] DEFAULT '{}';

CREATE INDEX idx_contact_submissions_merged_ticket_numbers 
ON contact_submissions USING GIN (merged_ticket_numbers) 
WHERE merged_ticket_numbers IS NOT NULL AND array_length(merged_ticket_numbers, 1) > 0;

COMMENT ON COLUMN contact_submissions.merged_ticket_numbers IS 'Array of ticket numbers that were merged and deleted into this primary ticket';