basalt / prisma/src / PrismaPluginOptions
Interface: PrismaPluginOptions<TClient>
Defined in: prisma/src/index.ts:195
Type Parameters
TClient
TClient = unknown
Properties
acquireTimeoutMs?
> optional acquireTimeoutMs?: number
Defined in: prisma/src/index.ts:243
Per-tenant pool: how long (ms) a request for a new tenant waits for a slot when all max clients are in use, before failing with TenantPoolExhaustedError (503). Default: 10_000.
assertMigrated?
> optional assertMigrated?: boolean | AssertMigratedOptions
Defined in: prisma/src/index.ts:252
Fail the boot unless the shared client's database is migrated: checks that _prisma_migrations exists (and, with { tables }, those tables too). Catches booting against the wrong database — e.g. a shell that exported another project's DATABASE_URL — at startup instead of as a P2021 on the first request. The error names the database and host, never the credentials. Needs client. Default: off.
client?
> optional client?: TClient
Defined in: prisma/src/index.ts:200
Shared-database mode: one client for everyone, typically already $extends(tenancyExtension()) so queries scope themselves via ctx().
destroy?
> optional destroy?: (client, tenantId) => void | Promise<void>
Defined in: prisma/src/index.ts:229
Eviction callback for the per-tenant pool (e.g. client.$disconnect()).
Parameters
client
TClient
tenantId
string
Returns
void | Promise<void>
forTenant?
> optional forTenant?: (tenantId) => TClient | Promise<TClient>
Defined in: prisma/src/index.ts:202
Database-per-tenant mode: factory creating the client for a tenant id.
Parameters
tenantId
string
Returns
TClient | Promise<TClient>
idleMs?
> optional idleMs?: number
Defined in: prisma/src/index.ts:237
Per-tenant pool: how long (ms) a client handed to a request stays "in use" and cannot be evicted. Keep it above your longest request. Default: 30_000. See TenantClientPoolOptions.idleMs.
max?
> optional max?: number
Defined in: prisma/src/index.ts:231
Max simultaneously open per-tenant clients. Default: 10
resolveClient?
> optional resolveClient?: (tenantId) => TClient | Promise<TClient>
Defined in: prisma/src/index.ts:227
Low-level escape hatch: resolve the client for a tenant yourself, bypassing the pool. shards is sugar over this. Called per request/switch.
Parameters
tenantId
string
Returns
TClient | Promise<TClient>
schemaPerTenant?
> optional schemaPerTenant?: object
Defined in: prisma/src/index.ts:209
Schema-per-tenant mode: one database, one PostgreSQL schema per tenant. Each tenant gets a client whose connection URL carries ?schema=<name>, so Prisma sets the search_path at connect time (reliable, unlike per-request search_path switching on a shared pool).
createClient
> createClient: (url) => TClient | Promise<TClient>
Builds a client from a URL, e.g. (url) => new PrismaClient({ datasourceUrl: url }).
Parameters
url
string
Returns
TClient | Promise<TClient>
prefix?
> optional prefix?: string
Schema name prefix. Default: 'tenant_'.
url
> url: string
Base connection URL (the schema param is set per tenant).
shards?
> optional shards?: ShardRouter<TClient>
Defined in: prisma/src/index.ts:222
Sharding mode: a fixed set of databases, routed by tenant id. Shard clients are long-lived and shared by many tenants (no eviction) — use for scale-out, not database-per-tenant isolation.