35 lines
1.1 KiB
SQL
35 lines
1.1 KiB
SQL
-- 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.'; |