Supabase table without row level security
A new table in the public schema with row level security never turned on in the same change.
Why it matters
Supabase apps talk to the database straight from the browser with the public anon key, which ships in every page. What stops a visitor from reading or rewriting a table is row level security. Agents create the table, wire it into the page, see it work, and stop, because nothing breaks locally without a policy.
Without it, anyone who copies the anon key from the page can select, update and delete every row of that table through the public API, signed in or not.
Example
+create table public.tags (
+ id uuid primary key default gen_random_uuid(),
+ note_id uuid references notes(id),
+ label text not null
+);
What it detects
- CREATE TABLE in the public schema (or with no schema) in a SQL file added or changed by the change.
- Only in Supabase projects: a supabase/ folder, supabase/config.toml, or @supabase packages in package.json.
- Quiet when the same change runs ALTER TABLE ... ENABLE ROW LEVEL SECURITY on that table, in any of its SQL files, for tables in other schemas, and in test fixtures.
What to do when it fires
Add alter table public.tags enable row level security; to the same migration, then a policy per action: for example, users may select and change only rows whose user_id is auth.uid().
If only the server should ever touch the table, enable row level security with no policies and use the service key on the server.