Compare
Stratum + Prisma
Type-safe ORM with declarative schema
Prisma is the most popular TypeScript ORM, known for its type-safe client and declarative schema language. Stratum works alongside Prisma — it does not replace it. Prisma handles your application's data modeling and queries. Stratum handles tenant hierarchy, config inheritance, isolation strategy, and compliance operations on the same PostgreSQL database.
Feature comparison
| Capability | Prisma | Stratum |
|---|---|---|
| Schema management | Prisma Migrate (declarative) | Stratum manages tenant tables only |
| RLS isolation | Manual — raw SQL in migrations | Automatic policy generation per tenant |
| Schema-per-tenant | Multiple PrismaClient instances | Single connection, search_path switching |
| Tenant context in queries | Manual where: { tenantId } on every query | Automatic via RLS or search_path |
| Config inheritance | Not available | Built-in, root-to-leaf resolution |
| Audit logging | Prisma middleware (manual) | Every mutation, actor-attributed |
| GDPR export/purge | Build it yourself | Built-in per-tenant operations |
| Type safety | Full generated types | TypeScript types + Zod schemas |
Getting started
prisma-with-stratum.ts
import { PrismaClient } from "@prisma/client"; import { Stratum } from "@stratum-hq/lib"; // Prisma handles your app schema const prisma = new PrismaClient(); // Stratum handles tenancy on the same database const stratum = new Stratum({ pool, autoMigrate: true }); await stratum.initialize(); // Create tenant hierarchy const org = await stratum.createTenant({ name: "Acme", slug: "acme" }); // Use Prisma for app queries, Stratum for tenant ops const users = await prisma.user.findMany({ where: { tenantId: org.id } });
Things to know
- Prisma Migrate and Stratum migrations are independent — run both during deployment.
- When using schema-per-tenant isolation, Prisma needs a separate client per schema or use $executeRaw to SET search_path.
- Prisma's connection pool and Stratum's pool are separate — configure both for your connection limit.
Start building with Prisma + Stratum
npm install @stratum-hq/lib pg