-- Fix is_user_banned function
CREATE OR REPLACE FUNCTION is_user_banned(p_user_id uuid)
RETURNS boolean
LANGUAGE plpgsql
STABLE
SECURITY DEFINER
SET search_path = public
AS $$
DECLARE
  v_banned BOOLEAN;
BEGIN
  SELECT banned INTO v_banned
  FROM profiles
  WHERE user_id = p_user_id;
  
  RETURN COALESCE(v_banned, false);
END;
$$;

DO $$ BEGIN RAISE NOTICE '✅ Fixed is_user_banned function'; END $$;