-- Add escalation tracking fields to content_submissions table
ALTER TABLE public.content_submissions 
ADD COLUMN IF NOT EXISTS escalated BOOLEAN DEFAULT FALSE,
ADD COLUMN IF NOT EXISTS escalation_reason TEXT,
ADD COLUMN IF NOT EXISTS escalated_at TIMESTAMP WITH TIME ZONE,
ADD COLUMN IF NOT EXISTS escalated_by UUID REFERENCES auth.users(id);

-- Add index for escalated submissions
CREATE INDEX IF NOT EXISTS idx_content_submissions_escalated 
ON public.content_submissions(escalated) 
WHERE escalated = TRUE;

-- Add index for escalated_by
CREATE INDEX IF NOT EXISTS idx_content_submissions_escalated_by 
ON public.content_submissions(escalated_by);

-- Add comments for documentation
COMMENT ON COLUMN public.content_submissions.escalated IS 'Whether this submission has been escalated to admin';
COMMENT ON COLUMN public.content_submissions.escalation_reason IS 'Reason for escalation';
COMMENT ON COLUMN public.content_submissions.escalated_at IS 'Timestamp when submission was escalated';
COMMENT ON COLUMN public.content_submissions.escalated_by IS 'User who escalated the submission';