Skip to content

Commit 9aff192

Browse files
authored
Make enhance function compatible with prisma v7
1 parent 76ef757 commit 9aff192

File tree

1 file changed

+6
-2
lines changed
  • packages/schema/src/plugins/enhancer/enhance

1 file changed

+6
-2
lines changed

packages/schema/src/plugins/enhancer/enhance/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,13 @@ export function enhance<DbClient extends object>(prisma: DbClient, context?: Enh
315315
}
316316

317317
private createLogicalPrismaImports(prismaImport: string, prismaClientImport: string, target: string | undefined) {
318+
const prismaVersion = getPrismaVersion();
319+
const runtimeLibraryImportSubPath = semver.gte(prismaVersion, '7.0.0') ? '/runtime/library' : '/runtime/client';
320+
318321
const prismaTargetImport = target === 'edge' ? `${prismaImport}/edge` : prismaImport;
319322
const runtimeLibraryImport = this.isNewPrismaClientGenerator
320323
? // new generator has these types only in "@prisma/client"
321-
'@prisma/client/runtime/library'
324+
'@prisma/client${runtimeLibraryImportSubPath}'
322325
: // old generator has these types generated with the client
323326
`${prismaImport}/runtime/library`;
324327

@@ -432,8 +435,9 @@ export type Enhanced<Client> =
432435
let generateCmd = `prisma generate --schema "${logicalPrismaFile}" --generator=${prismaClientGeneratorName}`;
433436

434437
const prismaVersion = getPrismaVersion();
435-
if (!prismaVersion || semver.gte(prismaVersion, '5.2.0')) {
438+
if (!prismaVersion || (semver.gte(prismaVersion, '5.2.0') && semver.lt(prismaVersion, '7.0.0'))) {
436439
// add --no-engine to reduce generation size if the prisma version supports
440+
// v7 has removed this option completely, because it no longer generates an engine
437441
generateCmd += ' --no-engine';
438442
}
439443

0 commit comments

Comments
 (0)