basalt / prisma/src / tenantSchema
Function: tenantSchema()
> tenantSchema(tenantId, options?): string
Defined in: prisma/src/schema.ts:50
Derives a safe PostgreSQL schema identifier for a tenant, and the mapping is injective: two different tenant ids never get the same schema.
- A canonical id (
[a-z0-9]words joined by single_, e.g.acme,acme_co) is used verbatim:tenant_acme. - Any other id (uppercase,
-,.,__, UUIDs, …) is encoded as a readable sanitized part plus__and a SHA-256-based suffix of the raw id:Acme-Co→tenant_acme_co__<16 hex>. Case or punctuation variants of an existing id therefore get their own schema instead of sharing it.
The result matches [a-z_][a-z0-9_]* and is at most 63 chars, so it is safe to quote and interpolate.
Parameters
tenantId
string
options?
TenantSchemaOptions = {}
Returns
string