Prisma 7 Setup
Eleven nestarc packages now document Prisma 7 support: tenancy, soft-delete, audit-log, feature-flag, pagination, api-keys, RBAC, outbox, inbox, webhook, and data-subject.
Compatibility Matrix
| Package | Release | Supported Prisma majors | Prisma 7 status |
|---|---|---|---|
@nestarc/api-keys | 0.4.0 | 5, 6, 7 | Verified packed consumer and PostgreSQL storage lane |
@nestarc/rbac | 0.2.2 | 5, 6, 7 | Verified packed consumer and PostgreSQL storage lane |
@nestarc/outbox | 0.4.1 | 5, 6, 7 | Verified packed consumer and PostgreSQL storage lane |
@nestarc/inbox | 0.2.0 | 7 (7.10.1+) | Required; installed tarball and PostgreSQL 16/18 validation |
@nestarc/webhook | 0.13.3 | 5, 6, 7 | Verified packed consumer and PostgreSQL storage lane |
@nestarc/data-subject | 0.3.0 | 5, 7 (7.10.0+); not 6 | Packed NestJS 11.2.7 / Prisma 7.10.0 consumer with PostgreSQL 16.15 |
@nestarc/tenancy | 0.16.4 | 6, 7 | Primary development and E2E target |
@nestarc/soft-delete | 0.7.6 | 5, 6, 7 | Primary development and PostgreSQL E2E target |
@nestarc/audit-log | 0.9.0 | 5, 6, 7 | Primary development and CI target |
@nestarc/feature-flag | 0.6.0 | 7 | Required Prisma major |
@nestarc/pagination | 0.3.2 | 5, 6, 7 | Primary development and CI target |
Prisma 7 requires Node.js ^20.19.0, ^22.12.0, or >=24.0.0. Individual package ranges are narrower: tenancy 0.16.4 and audit-log 0.9.0 require Node.js ^22.23.4 || ^24.22.1. API Keys 0.4 declares Node.js 22.13+ within the 22.x line or Node.js 24.x. Outbox 0.4 requires Node 22+, while Jobs 0.4 and idempotency 1.0 support Node 22/24. Use the intersection for a composition.
Install the PostgreSQL Adapter
Prisma 7 direct PostgreSQL connections use a driver adapter:
npm install @prisma/client @prisma/adapter-pg pg dotenv
npm install --save-dev prismaGenerate the Client
Use the prisma-client generator with an explicit output path. Keep the connection URL out of schema.prisma:
// prisma/schema.prisma
generator client {
provider = "prisma-client"
output = "../src/generated/prisma"
}
datasource db {
provider = "postgresql"
}Move the CLI datasource URL into Prisma Config:
// prisma.config.ts
import 'dotenv/config';
import { defineConfig, env } from 'prisma/config';
export default defineConfig({
schema: 'prisma/schema.prisma',
migrations: { path: 'prisma/migrations' },
datasource: { url: env('DATABASE_URL') },
});Generate the client after changing the schema:
npx prisma generateCreate the Runtime Client
Import PrismaClient from the configured output instead of the @prisma/client root:
import { PrismaPg } from '@prisma/adapter-pg';
import { PrismaClient } from './generated/prisma/client';
const adapter = new PrismaPg({
connectionString: process.env.DATABASE_URL!,
});
export const prisma = new PrismaClient({ adapter });Pass this client or one of its model delegates to nestarc exactly as you did with Prisma 6.
Package-Specific Steps
tenancy
Apply createPrismaTenancyExtension() to the generated base client. Prisma 6 applications can keep their current client construction. tenancy 0.16 supports Prisma 6 and 7, but no longer supports Prisma 5.
soft-delete
Cascade and relation filters require explicit DMMF metadata. Install @prisma/internals at exactly the same version as prisma, load the schema with getDMMF(), and copy its model, field and relation-key arrays into the PrismaDmmfLike shape. Pass this metadata as dmmf to both the extension and the module. Basic soft-delete filtering without cascade or relation filters does not need DMMF.
audit-log
For a complete 0.9.0 application using shared audit settings and Guard-time actor extraction, run the example or follow Installation.
The Prisma 7 generated client exports its Prisma namespace from the generated output. Audit-log 0.9.0 requires an explicit automatic-tracking consistency mode; use atomic-required with withAuditTransaction() for authoritative records. Pass the generated namespace to both the audited client and module:
import { Prisma, PrismaClient } from './generated/prisma/client';
import { createAuditedClient } from '@nestarc/audit-log';
export const prismaModule = { Prisma };
const client = createAuditedClient(basePrisma, {
consistency: 'atomic-required',
trackedModels: ['User'],
prismaModule,
});
await client.withAuditTransaction((tx) =>
tx.user.update({ where: { id }, data: { name: 'After' } }),
);Also pass prismaModule to AuditLogModule.forRoot() or forRootAsync().
Audit-log 0.9.0 supports NestJS 10, 11, and 12.0.1+; 12.0.0 is excluded. A larger package composition is limited to the intersection of every package's peer ranges.
For manual events on SQL Server, follow its separate provider setup. SQL Server automatic tracking remains unsupported in 0.9.0.
Atomic soft-delete lifecycle tuple
Use tenancy 0.16.4, audit-log 0.8.0, and soft-delete 0.7.6 with NestJS 10/11 and Node.js ^22.23.4 || ^24.22.1. Upgrade soft-delete 0.7.5 or earlier to 0.7.6 before installing this combination. The release checks cover Prisma 6.19.3 and 7.10.1 consumers on Node.js 22.23.4 and 24.22.1.
Soft-delete 0.7.6 excludes audit-log 0.9.0 from its optional peer range. Keep this lifecycle recipe on 0.8.0; the standalone 0.9.0 examples above do not widen that compatibility.
Configure ordinary per-query tenancy on a separate client derived from the same basePrisma. For audited lifecycle writes, build the client below from the base, using the generated Prisma namespace and deployed table mappings:
import { createAuditExtension, type AuditTransactionMethods } from '@nestarc/audit-log';
import { createPrismaSoftDeleteExtension } from '@nestarc/soft-delete';
import { tenancyTransactionCallback } from '@nestarc/tenancy';
import { Prisma } from './generated/prisma/client';
const lifecycleModels = ['User', 'Post'];
const lifecycleBatchCap = 1000;
const client = basePrisma
.$extends(createAuditExtension({
consistency: 'atomic-required',
trackedModels: lifecycleModels,
maxBatchRecords: lifecycleBatchCap,
tenantRequired: true,
tenantResolver: () => tenancyService.getCurrentTenantOrThrow(),
databaseMapping: {
User: { tableName: 'users' },
Post: { tableName: 'posts' },
},
prismaModule: { Prisma },
}))
.$extends(createPrismaSoftDeleteExtension({
softDeleteModels: lifecycleModels,
auditLifecycle: 'atomic-required',
auditMaxBatchRecords: lifecycleBatchCap,
cascade: { User: ['Post'] },
dmmf: prismaDmmf,
}));
// The second extension preserves the audit method at runtime.
const lifecycle = client as unknown as Pick<
AuditTransactionMethods<Prisma.TransactionClient>, 'withAuditTransaction'
>;
await lifecycle.withAuditTransaction(tenancyTransactionCallback(
tenancyService,
async (tx: Prisma.TransactionClient) => tx.user.delete({ where: { id } }),
));Inject the same lifecycle client into SoftDeleteModule and match its model list, cascade graph, DMMF, and batch cap. Include each cascade child in audit tracking and configure deployed table and primary-key mappings where needed. Run restore and purge service operations inside the wrapped callback. Keep a single authorized tenant for the transaction and pass required tenant fields explicitly on inserts. See Prisma Extension Chaining for the complete NestJS wiring.
feature-flag
feature-flag 0.6 uses Prisma 7 for its default PostgreSQL repository. Create the generated client with a driver adapter, then pass it through the prisma module option. Versions 0.4 → 0.5 require this client setup; 0.5 → 0.6 requires no database migration. Version 0.6 also accepts a custom repository instance without a Prisma instance, but the published npm peer declarations still apply. Review partial-rollout cohorts because explicit targetingKey and registry bucketBy now take effect consistently.
pagination
Pagination accepts a normal Prisma model delegate, so the pagination API does not change. Only standalone client construction changes for Prisma 7.
inbox
Inbox 0.2.0 requires Prisma ^7.10.1 and NestJS ^11.2.8. Pass your application's generated Prisma client with a matching PostgreSQL adapter to InboxModule; perform handler writes through context.tx so they commit with inbox completion. Apply the packaged schema v2 SQL before startup: changing Prisma client construction does not create the Inbox tables. PostgreSQL 16 and 18 are the recorded integration-test targets. Follow Inbox installation for the schema and client setup.
data-subject
Data-subject 0.3.0 has a narrower optional Prisma peer range: ^5.0.0 || ^7.10.0; Prisma 6 is excluded. Its published compatibility record covers NestJS 10.4.22 / Prisma 5.22.0 and NestJS 11.2.7 / Prisma 7.10.0 against PostgreSQL 16.15. For the Prisma 7 lane, use a generated CommonJS client and matching PostgreSQL adapter, and bind business delegates to the execution transaction. See data-subject installation and the release compatibility record.
Upgrade Checklist
- Upgrade to the package releases in the compatibility matrix.
- Use a Prisma 7-compatible Node.js version.
- Move the datasource URL into
prisma.config.ts. - Switch to
provider = "prisma-client"and set an explicit output. - Install the adapter for your database and pass it to
PrismaClient. - Update imports to the generated client path.
- Apply the soft-delete or audit-log package-specific configuration above. For the combined lifecycle bridge, preserve the extension order and align model, mapping, batch-cap, and DMMF configuration.
- Regenerate the client and run type, integration, and migration checks before deployment.
Prisma 6 consumers of tenancy, soft-delete, audit-log, and pagination do not need to adopt the Prisma 7 client layout until they upgrade Prisma itself.
Additional Prisma 7 packages
API Keys 0.4, RBAC 0.2.2, Outbox 0.4, and Webhook 0.13.3 retain Prisma 5/6 and add verified Prisma 7 consumers. Pass the generated adapter-backed client into their existing storage/module integrations.
- API Keys: use the shipped Prisma 7 schema/config examples; review request authorization, safe list projections, and custom rotation changes in the 0.4 checklist. TypeScript 5.3+ is required.
- RBAC: the role/binding schema is unchanged. Both CLI and client peers accept
>=5 <8; Prisma 8 is unsupported. Keep authenticated identity sources consistent. - Outbox: apply the unified schema upgrade after draining old pollers when coming from 0.1/0.2. Version 0.4 retains the 0.3 schema, requires periodic polling, and rejects old admin cursors. Switching client construction does not replace the SQL or application migration. Jobs 0.4.2 accepts Outbox
^0.2.1 || ^0.3.0 || ^0.4.0; the combined workflow now pairs it with Outbox 0.4.1 and explicit stop-before-close ordering. - Webhook: use 0.13.3 for the encrypting-vault provisioning fix, retaining the Prisma 7 retention cutoff, correlation, replay-limit, and retry/purge locking fixes; an existing 0.13.0 schema needs no new patch migration.
Tenancy + API Keys + RBAC + audit-log now share NestJS 10/11 and Prisma 6/7. NestJS 12 support in individual packages does not widen tenancy, jobs, or webhook's 10/11 boundary.