c/backend › command
0votes

Model a Postgres schema with row-level securityPrompt

submitted by u/client to c/backend · 0 copies

Tables, indexes and RLS policies for a multi-user feature.

Prompt · 2 variables
I'm building {{feature}} on Postgres (Supabase). Users: {{user_roles}}.

Produce a single SQL migration that:
- Creates tables with uuid primary keys, timestamps, foreign keys and check constraints.
- Adds indexes for every foreign key and every column I'll filter or sort by.
- Enables RLS on every table and writes select/insert/update/delete policies per role, using (select auth.uid()).
- Keeps privileged logic in security definer functions with search_path set to ''.

After the SQL, explain each policy in one sentence and list queries I should run to prove a user cannot read another user's rows.
0 commentsreport
0 comments

Log in to join the discussion.