Schema Isolation
PostgreSQL schema-per-tenant with automatic LRU pool management. Complete data isolation with zero cross-tenant access.
Configure isolation
Schema isolation, tenant context propagation, and parallel migrations for PostgreSQL. Build SaaS applications with confidence.
Get up and running in under 5 minutes
npm install drizzle-multitenant drizzle-orm pg// tenant.config.ts
import { defineConfig } from 'drizzle-multitenant';
import * as schema from './schema';
export default defineConfig({
connection: { url: process.env.DATABASE_URL! },
isolation: {
strategy: 'schema',
schemaNameTemplate: (id) => `tenant_${id}`,
},
schemas: { tenant: schema },
});// app.ts
import { createTenantManager } from 'drizzle-multitenant';
import config from './tenant.config';
const tenants = createTenantManager(config);
// Type-safe database for each tenant
const db = tenants.getDb('acme');
const users = await db.select().from(schema.users);