Lovable database

RLS Allows SELECT But Blocks INSERT/UPDATE

Users can read data from table but cannot insert or update. 'permission denied' error on insert/update despite having select access. RLS policies inconsistently applied across operations.

Each database operation (SELECT, INSERT, UPDATE, DELETE) needs its own RLS policy. Common mistake is creating only SELECT policy and assuming others inherit.

Error Messages You Might See

permission denied for table insert or update on table violates policy Violation of row-level security policy
permission denied for tableinsert or update on table violates policyViolation of row-level security policy

Common Causes

  1. INSERT policy doesn't exist or uses wrong auth check
  2. WITH CHECK clause missing from INSERT policy
  3. UPDATE policy missing or references wrong columns
  4. Policy targets wrong role (anon vs authenticated)
  5. Multiple conflicting policies with AND logic

How to Fix It

Create separate policies for each operation:

-- SELECT policy
CREATE POLICY "Read own data" ON users
FOR SELECT USING (auth.uid() = id);

-- INSERT policy  
CREATE POLICY "Create own user" ON users
FOR INSERT WITH CHECK (auth.uid() = id);

-- UPDATE policy
CREATE POLICY "Update own data" ON users
FOR UPDATE USING (auth.uid() = id)
WITH CHECK (auth.uid() = id);

Real developers can help you.

Mehdi Ben Haddou Mehdi Ben Haddou - Founder of Chessigma (1M+ users) & many small projects - ex Founding Engineer @Uplane (YC F25) - ex Software Engineer @Amazon and @Booking.com legrab legrab I'll fill this later Antriksh Narang Antriksh Narang 5 years+ Experienced Dev (Specially in Web Development), can help in python, javascript, react, next.js and full stack web dev technologies. Yovel Cohen Yovel Cohen I got a lot of experience in building Long-horizon AI Agents in production, Backend apps that scale to millions of users and frontend knowledge as well. Jared Hasson Jared Hasson Full time lead founding dev at a cyber security saas startup, with 10 yoe and a bachelor's in CS. Building & debugging software products is what I've spent my time on for forever BurnHavoc BurnHavoc Been around fixing other peoples code for 20 years. Taufan Taufan I’m a product-focused engineer and tech leader who builds scalable systems and turns ideas into production-ready platforms. Over the past years, I’ve worked across startups and fast-moving teams, leading backend architecture, improving system reliability, and shipping products used by thousands of users. My strength is not just writing code — but connecting product vision, technical execution, and business impact. MFox MFox Full-stack professional senior engineer (15+years). Extensive experience in software development, qa, and IP networking. Luca Liberati Luca Liberati I work on monoliths and microservices, backends and frontends, manage K8s clusters and love to design apps architecture Vlad Temian Vlad Temian 15+ years shipping production infrastructure for startups. Former CTO at qed.builders (acquired by The Sandbox). Cursor ambassador and agentic tooling builder. I've scaled systems, automated deployments, and built observability tools for AI coding workflows. I specialize in taking vibe-coded apps from broken prototype to production-ready: fixing Supabase auth/RLS, Stripe integrations, deployment pipelines, and cleaning up AI-generated spaghetti. I build tools in this space (agentprobe, claudebin, micode) and understand both sides: how AI generates code and why it breaks. https://blog.vtemian.com/

You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.

Get Help

Frequently Asked Questions

What's the difference between USING and WITH CHECK?

USING: checks rows before operation (for SELECT/UPDATE/DELETE). WITH CHECK: validates new row data (for INSERT/UPDATE).

Do I need separate policy per operation?

Yes, each operation (SELECT, INSERT, UPDATE, DELETE) needs its own FOR clause and policy.

Related Lovable Issues

Can't fix it yourself?
Real developers can help.

You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.

Get Help