38980-vm/app-9w9pd00g5j41/supabase/migrations/00095_fix_site_settings_rls_policies.sql
2026-03-04 18:25:09 +00:00

35 lines
1.1 KiB
SQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- Fix site_settings RLS policies
-- Remove duplicate INSERT policies and ensure proper permissions
-- Drop existing policies
DROP POLICY IF EXISTS "Adminler site ayarlarını oluşturabilir" ON site_settings;
DROP POLICY IF EXISTS "Admins can insert site settings" ON site_settings;
DROP POLICY IF EXISTS "Adminler site ayarlarını güncelleyebilir" ON site_settings;
-- Create clean, simple policies
-- Anyone can read site settings (already exists: "Herkes site ayarlarını okuyabilir")
-- Only admins can insert site settings
CREATE POLICY "Admins can insert site settings"
ON site_settings
FOR INSERT
TO authenticated
WITH CHECK (is_admin());
-- Only admins can update site settings
CREATE POLICY "Admins can update site settings"
ON site_settings
FOR UPDATE
TO authenticated
USING (is_admin())
WITH CHECK (is_admin());
-- Only admins can delete site settings
CREATE POLICY "Admins can delete site settings"
ON site_settings
FOR DELETE
TO authenticated
USING (is_admin());
-- Add helpful comment
COMMENT ON TABLE site_settings IS 'Site-wide settings. Public read, admin write. Clerk key stored here for dynamic loading.';