From 5d35fdc326a4b881cb1584dfece3e2e4f24c21a6 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Tue, 11 Nov 2025 01:12:56 +0000 Subject: [PATCH] Enable alert resolution policy Allow moderators to resolve rate limit alerts by adding UPDATE policy on rate_limit_alerts and granting UPDATE to authenticated users. This completes enabling the Resolve action for alerts. --- ...4_62ebd15f-c783-489a-9088-9dc3e0268f8e.sql | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 supabase/migrations/20251111011244_62ebd15f-c783-489a-9088-9dc3e0268f8e.sql 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