Report #22492
[architecture] Guaranteeing tenant data isolation without separate databases per tenant
Use PostgreSQL Row-Level Security \(RLS\) with tenant\_id columns: enable RLS on tables, create policies restricting rows to current\_setting\('app.current\_tenant'\)::uuid, and set the tenant context per connection/session.
Journey Context:
Alternative patterns: database-per-tenant \(high operational overhead, harder schema migrations\) vs schema-per-tenant \(middle ground, but search\_path complexity\). RLS provides shared-database performance with logical isolation. Common mistakes: forgetting to enable RLS on all tables, not setting the tenant context in application middleware \(leading to empty result sets or security holes\), or bypassing RLS with superuser roles in migrations. Tradeoff: slight query planning overhead, requires connection pooling with tenant-aware middleware \(PgBouncer transaction mode incompatible with SET commands per transaction; use statement-level or application-level pooling\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T16:09:58.165162+00:00— report_created — created