Files
flyer-crawler.projectium.com/supabase/migrations/20251111225145_secure_public_read_policies.sql
Torben Sorensen d5d46bc143
Some checks failed
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Failing after 17s
db work and flyer processing to anon table
2025-11-12 19:59:00 -08:00

37 lines
1.8 KiB
SQL

-- ============================================================================
-- MIGRATION: Secure Public Read Policies
-- ============================================================================
-- This migration replaces overly permissive "Allow full public access" RLS policies
-- with more secure, read-only policies for public data. This ensures that
-- anonymous users can view data like flyers and items, but cannot modify or delete it.
-- This fixes the issue where non-logged-in users could not see processed flyers.
-- Secure 'stores' table
DROP POLICY IF EXISTS "Allow full public access" ON public.stores;
CREATE POLICY "Public read access" ON public.stores FOR SELECT USING (true);
-- Secure 'categories' table
DROP POLICY IF EXISTS "Allow full public access" ON public.categories;
CREATE POLICY "Public read access" ON public.categories FOR SELECT USING (true);
-- Secure 'flyers' table
DROP POLICY IF EXISTS "Allow full public access" ON public.flyers;
CREATE POLICY "Public read access" ON public.flyers FOR SELECT USING (true);
-- Secure 'flyer_items' table
DROP POLICY IF EXISTS "Allow full public access" ON public.flyer_items;
CREATE POLICY "Public read access" ON public.flyer_items FOR SELECT USING (true);
-- Secure 'master_grocery_items' table
DROP POLICY IF EXISTS "Allow full public access" ON public.master_grocery_items;
CREATE POLICY "Public read access" ON public.master_grocery_items FOR SELECT USING (true);
-- Secure 'brands' table
DROP POLICY IF EXISTS "Allow full public access" ON public.brands;
CREATE POLICY "Public read access" ON public.brands FOR SELECT USING (true);
-- Secure 'products' table
DROP POLICY IF EXISTS "Allow full public access" ON public.products;
CREATE POLICY "Public read access" ON public.products FOR SELECT USING (true);