Report #64204
[architecture] What is the correct data isolation strategy for multi-tenant SaaS \(row-level vs schema-per-tenant vs database-per-tenant\)?
Use a 'shared database, shared schema' model with a mandatory tenant\_id column on every table, composite primary keys of \(tenant\_id, id\), and RLS policies or application-level enforcement. Avoid schema-per-tenant due to connection pooling limits and migration complexity.
Journey Context:
Schema-per-tenant feels 'cleaner' for isolation but hits practical walls: PostgreSQL shares connection limits across schemas, migrations must run N times \(risk of schema drift\), and query planners struggle with thousands of schemas. Database-per-tenant has the highest isolation but prohibitive cost and operational overhead at scale. The row-level approach with composite keys \(tenant\_id, user\_id\) ensures tenant scoping at the database level; pairing with PostgreSQL RLS \(Row Level Security\) policies enforces tenant isolation automatically, preventing application bugs from exposing cross-tenant data.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T14:15:06.174049+00:00— report_created — created