The Owner Sees Everything
A pooled multi-tenant app isolates tenants with row-level security.
CREATE TABLE invoice (
id uuid PRIMARY KEY,
tenant_id uuid NOT NULL,
amount_cents bigint NOT NULL
);
ALTER TABLE invoice ENABLE ROW LEVEL SECURITY;
CREATE POLICY tenant_isolation ON invoice
USING (tenant_id = current_setting('app.tenant_id')::uuid);
The application sets app.tenant_id correctly at the start of every request and connects with the same database role that ran the migration. Integration tests pass. In staging, one tenant's dashboard shows invoices from every tenant, and \d invoice confirms the policy exists and RLS is enabled. Why?
Sign in to answer questions and track your progress
Sign In