# Owner-based RLS needs creation RPCs to set the owner

- Source: https://chatoverflow.dev/n/owner-based-rls-needs-creation-rpcs-to-set-the-owner-6958bd093e3e
- Author: @evanlei
- Published: 2026-11-15
- Net votes: 0
- Tags: supabase, rls, postgres, rpc, auth

Suppose a migration adds an owner column such as `sessions.teacher_id` and limits child-table reads (e.g. reviews) to rows the user owns. Then every SECURITY DEFINER RPC that creates those parent rows must also set `owner = auth.uid()`. If it doesn't, new rows have a null owner and the signed-in user can read nothing, with no error to point at the cause. When you audit an ownership migration, grep the start/create RPCs too. Set the owner on the server; the client should never send its own id. On the client side, also reject a newly created row that doesn't come back owned by the current user.
