:active → Created, schema not yet provisioned
:provisioned → PostgreSQL schema created and ready
:suspended → Access disabled (data preserved)
:deleted → Soft delete (schema can be deprovisioned)
Multi-tenancy with schema-per-tenant isolation on PostgreSQL. Provides tenant CRUD, schema provisioning, tenant resolution, and cross-module integration.
| Requires PostgreSQL. Not supported with SQLite or H2. |
| Namespace | Purpose |
|---|---|
| Pure functions: slug validation, schema name generation, prepare-tenant, decisions |
| Protocols: |
| Malli schemas: |
| Service layer with observability interceptors |
| Database CRUD with case conversion |
| PostgreSQL schema provisioning/deprovisioning |
| REST API handlers (CRUD + provision/suspend/activate) |
| Integrant lifecycle ( |
:active → Created, schema not yet provisioned
:provisioned → PostgreSQL schema created and ready
:suspended → Access disabled (data preserved)
:deleted → Soft delete (schema can be deprovisioned)
;; Slug: lowercase alphanumeric + hyphens, 2–100 chars
(tenant/valid-slug? "acme-corp") ;=> true
(tenant/valid-slug? "ACME") ;=> false (uppercase)
(tenant/valid-slug? "acme_corp") ;=> false (underscore)
;; Slug → PostgreSQL schema name
(tenant/slug->schema-name "acme-corp") ;=> "tenant_acme_corp"
(require '[boundary.tenant.shell.provisioning :as provisioning])
;; Provision: creates PostgreSQL schema and copies table structure
(provisioning/provision-tenant! db-ctx tenant)
;=> {:success? true :schema-name "tenant_acme_corp" :table-count 5}
;; Execute queries in tenant schema context
(provisioning/with-tenant-schema db-ctx "tenant_acme_corp"
(fn [tx]
;; SET search_path TO tenant_acme_corp, public
(jdbc/execute! tx ["SELECT * FROM orders"])))
POST /api/tenants # Create tenant
GET /api/tenants # List tenants
GET /api/tenants/:slug # Get tenant
PATCH /api/tenants/:slug # Update tenant
POST /api/tenants/:slug/provision # Provision schema
POST /api/tenants/:slug/suspend # Suspend tenant
POST /api/tenants/:slug/activate # Activate tenant
DELETE /api/tenants/:slug # Soft delete
clojure -M:test:db/h2 :tenant
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |