{"-- Create table to link alert templates with event types
CREATE TABLE public.alert_template_events (
  id UUID NOT NULL DEFAULT gen_random_uuid() PRIMARY KEY,
  alert_template_id UUID NOT NULL REFERENCES public.alert_templates(id) ON DELETE CASCADE,
  event_type_id UUID NOT NULL REFERENCES public.event_types(id) ON DELETE CASCADE,
  created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
  UNIQUE(alert_template_id, event_type_id)
)","-- Enable RLS
ALTER TABLE public.alert_template_events ENABLE ROW LEVEL SECURITY","-- RLS policies for alert_template_events
CREATE POLICY \"Super admin can manage alert template events\"
ON public.alert_template_events
FOR ALL
TO authenticated
USING (is_current_user_super_admin())","CREATE POLICY \"Users can view alert template events\"
ON public.alert_template_events
FOR SELECT
TO authenticated
USING (true)"}