Integration Cheatsheet 06 — Multi-Tenancy Across the Stack
Cheatsheet: tenant context, RLS policies, per-request session, isolation tests.
Cheatsheet: tenant context, RLS policies, per-request session, isolation tests.
Multi-DB migrations via Alembic: -t multidb template, schema-per-tenant strategies, parallelism.
Cheatsheet: multidb template, schema-per-tenant env.py, parallel migrations.
Postgres RLS for multi-tenant SQLAlchemy: defining policies, setting tenant context per request, and integration with FastAPI.
Cheatsheet: enable RLS, write policies, set tenant per request, application role without BYPASSRLS.
Cheatsheet: per-tenant schemas, search_path, multi-schema Alembic env, onboarding.
Cheatsheet: per-tenant engine cache, connection routing, multi-DB Alembic, onboarding.
Cheatsheet: shared DB + tenant_id, schema-per-tenant, DB-per-tenant, query filters, context propagation.
Practical multi-tenancy: row-level (cheapest), schema-per-tenant (isolation), DB-per-tenant (compliance). RLS, query patterns, and operational realities.
Three multi-tenant patterns: shared (tenant_id everywhere), pooled (schema-per-tenant), per-tenant DB. The decision matrix by scale, isolation, compliance, and cost.