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
Common Causes
- INSERT policy doesn't exist or uses wrong auth check
- WITH CHECK clause missing from INSERT policy
- UPDATE policy missing or references wrong columns
- Policy targets wrong role (anon vs authenticated)
- 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.
You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.
Get Help