Multi-Tenancy
Build SaaS applications with built-in tenant isolation, quotas, and change data capture.
Tenant Management
Create Tenant
\tenant create acme_corp enterprise schemaList Tenants
\tenantsSwitch Tenant Context
\tenant use acme_corpIsolation Levels
| Level | Description |
|---|---|
shared | Logical isolation via tenant_id column |
schema | Per-tenant schema isolation |
database | Full database isolation |
Quotas
Set Quotas
\tenant quota set acme storage=10GB connections=50 qps=1000View Usage
\tenant usage acmePlans
\tenant plans # List plans\tenant plan create pro tier=2 storage=50GB\tenant plan acme_corp pro # Assign planChange Data Capture (CDC)
\tenant cdc # View recent events\tenant cdc export events.json # Export to fileIsolation over the Network
Row-level security policies apply to PostgreSQL wire sessions and to REST requests. A REST request runs as the database role named in its token’s sub claim. Give each tenant its own role, write policies against current_user, and never issue tenant tokens for superusers, who bypass row-level security. See the multi-tenant example.
REST endpoints for tenant management are planned. Until then, manage tenants with the REPL commands above.
Related
- Row-Level Security: policy-based access control
- Authentication: roles and REST tokens