Files
thrilltrack-explorer/supabase/migrations/20251002203926_30f32ec3-acb6-4155-b237-de0d59cce0bf.sql
gpt-engineer-app[bot] 63e8370991 Refactor realtime hooks
2025-10-02 20:39:37 +00:00

19 lines
796 B
PL/PgSQL

-- Phase 1: Fix Realtime Subscriptions - Add realtime access helper function
-- Note: Realtime schema permissions are managed by Supabase automatically
-- Tables are already in the supabase_realtime publication with REPLICA IDENTITY FULL
-- Create a function to verify realtime access for moderators
CREATE OR REPLACE FUNCTION public.check_realtime_access()
RETURNS boolean
LANGUAGE plpgsql
STABLE SECURITY DEFINER
SET search_path = public
AS $$
BEGIN
-- Check if user is a moderator (can access realtime moderation features)
RETURN is_moderator(auth.uid());
END;
$$;
-- Add comment to the function
COMMENT ON FUNCTION public.check_realtime_access() IS 'Checks if the current user has permission to access realtime moderation features. Returns true for moderators, admins, and superusers.';