-- Add UPDATE policy for resolving alerts
CREATE POLICY "Moderators can resolve alerts"
ON public.rate_limit_alerts
FOR UPDATE
TO authenticated
USING (
  EXISTS (
    SELECT 1 FROM public.user_roles
    WHERE user_id = auth.uid()
    AND role IN ('admin', 'moderator', 'superuser')
  )
)
WITH CHECK (
  EXISTS (
    SELECT 1 FROM public.user_roles
    WHERE user_id = auth.uid()
    AND role IN ('admin', 'moderator', 'superuser')
  )
);

-- Grant UPDATE permission
GRANT UPDATE ON public.rate_limit_alerts TO authenticated;