Files
acmcc/supabase/migrations/20260317224247_2bf55ff2-b4a4-43f1-8445-ffa7b2993451.sql
T
2026-06-01 20:19:26 -04:00

39 lines
1.2 KiB
SQL

-- Allow any authenticated user to insert their own comments
CREATE POLICY "Authenticated users can insert own entity_comments"
ON public.entity_comments
FOR INSERT
TO authenticated
WITH CHECK (auth.uid() = user_id);
-- Allow any authenticated user to insert their own votes
CREATE POLICY "Authenticated users can insert own entity_votes"
ON public.entity_votes
FOR INSERT
TO authenticated
WITH CHECK (auth.uid() = user_id);
-- Allow any authenticated user to update their own votes
CREATE POLICY "Authenticated users can update own entity_votes"
ON public.entity_votes
FOR UPDATE
TO authenticated
USING (auth.uid() = user_id)
WITH CHECK (auth.uid() = user_id);
-- Allow any authenticated user to delete their own votes
CREATE POLICY "Authenticated users can delete own entity_votes"
ON public.entity_votes
FOR DELETE
TO authenticated
USING (auth.uid() = user_id);
-- Allow any authenticated user to delete their own comments
CREATE POLICY "Authenticated users can delete own entity_comments"
ON public.entity_comments
FOR DELETE
TO authenticated
USING (auth.uid() = user_id);
-- Enable realtime for both tables
ALTER PUBLICATION supabase_realtime ADD TABLE public.entity_votes;
ALTER PUBLICATION supabase_realtime ADD TABLE public.entity_comments;