From 624de77992b1957aa35eeb28d43bca5147306a5a Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sun, 28 Sep 2025 23:41:01 +0000 Subject: [PATCH] Fix: Update is_moderator function --- ...234051_47e9ad4e-e44a-4707-94ab-0431b7ab8a41.sql | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 supabase/migrations/20250928234051_47e9ad4e-e44a-4707-94ab-0431b7ab8a41.sql diff --git a/supabase/migrations/20250928234051_47e9ad4e-e44a-4707-94ab-0431b7ab8a41.sql b/supabase/migrations/20250928234051_47e9ad4e-e44a-4707-94ab-0431b7ab8a41.sql new file mode 100644 index 00000000..468ebce5 --- /dev/null +++ b/supabase/migrations/20250928234051_47e9ad4e-e44a-4707-94ab-0431b7ab8a41.sql @@ -0,0 +1,14 @@ +-- Update is_moderator function to include superusers +CREATE OR REPLACE FUNCTION public.is_moderator(_user_id uuid) + RETURNS boolean + LANGUAGE sql + STABLE SECURITY DEFINER + SET search_path TO 'public' +AS $function$ + SELECT EXISTS ( + SELECT 1 + FROM public.user_roles + WHERE user_id = _user_id + AND role IN ('moderator', 'admin', 'superuser') + ) +$function$; \ No newline at end of file