Skip to content

Prisma 7 Setup ​

Nine nestarc packages now document Prisma 7 support: tenancy, soft-delete, audit-log, feature-flag, pagination, api-keys, RBAC, outbox, and webhook.

Compatibility Matrix ​

PackageReleaseSupported Prisma majorsPrisma 7 status
@nestarc/api-keys0.4.05, 6, 7Verified packed consumer and PostgreSQL storage lane
@nestarc/rbac0.2.25, 6, 7Verified packed consumer and PostgreSQL storage lane
@nestarc/outbox0.3.05, 6, 7Verified packed consumer and PostgreSQL storage lane
@nestarc/webhook0.13.15, 6, 7Verified packed consumer and PostgreSQL storage lane
@nestarc/tenancy0.16.16, 7Primary development and E2E target
@nestarc/soft-delete0.7.25, 6, 7Primary development and PostgreSQL E2E target
@nestarc/audit-log0.7.05, 6, 7Primary development and CI target
@nestarc/feature-flag0.5.07Required Prisma major
@nestarc/pagination0.3.05, 6, 7Primary 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, api-keys 0.4, and audit-log 0.7 require Node.js 22.13+ within the 22.x line or Node.js 24.x. Outbox 0.3 requires Node 22+, while Jobs 0.4 supports Node 22/24. Use the intersection for a composition.

Install the PostgreSQL Adapter ​

Prisma 7 direct PostgreSQL connections use a driver adapter:

bash
npm install @prisma/client @prisma/adapter-pg pg dotenv
npm install --save-dev prisma

Generate the Client ​

Use the prisma-client generator with an explicit output path. Keep the connection URL out of schema.prisma:

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:

typescript
// 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:

bash
npx prisma generate

Create the Runtime Client ​

Import PrismaClient from the configured output instead of the @prisma/client root:

typescript
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 pass the result as dmmf to both the extension and module configuration. Basic soft-delete filtering without cascade or relation filters does not need DMMF.

See soft-delete installation.

audit-log ​

For a complete 0.7.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.5.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:

typescript
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 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.

Atomic soft-delete lifecycle tuple

The historical combined example below pairs audit-log 0.5.0 with soft-delete 0.7.2 and uses the fixed tenancy → audit-log → soft-delete order. New audit-log 0.7.0 integrations need the soft-delete 0.7.4 bridge. Do not use tenancy 0.16's tenancyTransaction() as a wrapper for withAuditTransaction().

The combined audit-log 0.5.0 / soft-delete 0.7.2 bridge's shared NestJS peer range is 10/11; audit-log's NestJS 12.0.1+ support applies when the installed package set also accepts that major.

typescript
const lifecycleModels = ['User', 'Post'];
const lifecycleBatchCap = 1000;

const client = basePrisma
  .$extends(createPrismaTenancyExtension(tenancyService, {
    interactiveTransactionSupport: true,
  }))
  .$extends(createAuditExtension({
    consistency: 'atomic-required',
    trackedModels: lifecycleModels,
    maxBatchRecords: lifecycleBatchCap,
    databaseMapping: {
      User: { tableName: 'users' },
      Post: { tableName: 'posts' },
    },
    prismaModule,
  }))
  .$extends(createPrismaSoftDeleteExtension({
    softDeleteModels: lifecycleModels,
    auditLifecycle: 'atomic-required',
    auditMaxBatchRecords: lifecycleBatchCap,
    cascade: { User: ['Post'] },
    dmmf: prismaDmmf,
  }));

await client.withAuditTransaction((tx) =>
  tx.user.delete({ where: { id } }),
);

Use the same soft-delete models, cascade graph, DMMF, and batch cap in SoftDeleteModule. Every lifecycle and cascade model must be audit-tracked with its exact deployed databaseMapping and custom primary-key metadata. Restore and purge service calls must also run inside withAuditTransaction() using the same fully composed client. Explicit best-effort cannot power this bridge; rollback can leave orphan success rows and transaction-local diffs can be stale. See Prisma Extension Chaining for the complete NestJS wiring.

feature-flag ​

feature-flag 0.5 requires Prisma 7. Create the generated client with a driver adapter, then pass it through the existing prisma module option. No database migration is required when upgrading from 0.4.

pagination ​

Pagination accepts a normal Prisma model delegate, so the pagination API does not change. Only standalone client construction changes for Prisma 7.

Upgrade Checklist ​

  1. Upgrade to the package releases in the compatibility matrix.
  2. Use a Prisma 7-compatible Node.js version.
  3. Move the datasource URL into prisma.config.ts.
  4. Switch to provider = "prisma-client" and set an explicit output.
  5. Install the adapter for your database and pass it to PrismaClient.
  6. Update imports to the generated client path.
  7. 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.
  8. 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.3, and Webhook 0.13.1 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 0.3 upgrade after draining old pollers. Switching client construction does not replace this database migration.
  • Webhook: use 0.13.1 for the Prisma 7 retention cutoff fix; 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.

Released under the MIT License.