diff --git a/supabase/migrations/20251111011244_62ebd15f-c783-489a-9088-9dc3e0268f8e.sql b/supabase/migrations/20251111011244_62ebd15f-c783-489a-9088-9dc3e0268f8e.sql new file mode 100644 index 00000000..3f7a2e5d --- /dev/null +++ b/supabase/migrations/20251111011244_62ebd15f-c783-489a-9088-9dc3e0268f8e.sql @@ -0,0 +1,22 @@ +-- 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; \ No newline at end of file