🔧 Error Fixes
· 1 min read

Supabase: New Row Violates Row-Level Security Policy — How to Fix It


new row violates row-level security policy for table "posts"

Row Level Security (RLS) is blocking your insert/update.

Fix 1: Add an RLS policy

-- Allow authenticated users to insert their own rows
CREATE POLICY "Users can insert own posts"
ON posts FOR INSERT
TO authenticated
WITH CHECK (auth.uid() = user_id);

Fix 2: Check existing policies

SELECT * FROM pg_policies WHERE tablename = 'posts';

Fix 3: Temporarily disable RLS (dev only!)

ALTER TABLE posts DISABLE ROW LEVEL SECURITY;

⚠️ Never do this in production.