@@ -3,7 +3,7 @@ import { binaryForRuntime, BuildContext, BuildExtension } from "@trigger.dev/cor
33import assert from "node:assert" ;
44import { existsSync , statSync } from "node:fs" ;
55import { cp , readdir , readFile } from "node:fs/promises" ;
6- import { dirname , join , resolve } from "node:path" ;
6+ import { basename , dirname , join , resolve } from "node:path" ;
77import { resolvePathSync as esmResolveSync } from "../imports/mlly.js" ;
88import { resolvePackageJSON } from "pkg-types" ;
99import { LoadConfigFromFileError } from "@prisma/config" ;
@@ -543,8 +543,12 @@ export class PrismaLegacyModeExtension implements BuildExtension {
543543
544544 // Detect if this is a multi-file schema (directory) or single file schema
545545 const isMultiFileSchema = statSync ( this . _resolvedSchemaPath ) . isDirectory ( ) ;
546+ const schemaDir = dirname ( this . _resolvedSchemaPath ) ;
546547 const usingSchemaFolder =
547- ! isMultiFileSchema && dirname ( this . _resolvedSchemaPath ) . endsWith ( "schema" ) ;
548+ ! isMultiFileSchema &&
549+ ( await readdir ( schemaDir ) ) . some (
550+ ( file ) => file . endsWith ( ".prisma" ) && file !== basename ( this . _resolvedSchemaPath )
551+ ) ;
548552
549553 context . logger . debug ( `Schema detection` , {
550554 isMultiFileSchema,
@@ -633,8 +637,6 @@ export class PrismaLegacyModeExtension implements BuildExtension {
633637 ) } node_modules/prisma/build/index.js generate ${ generatorFlags . join ( " " ) } ` // Don't add the --schema flag when using directory
634638 ) ;
635639 } else if ( usingSchemaFolder ) {
636- const schemaDir = dirname ( this . _resolvedSchemaPath ) ;
637-
638640 prismaDir = dirname ( schemaDir ) ;
639641
640642 context . logger . debug ( `Using the schema folder: ${ schemaDir } ` ) ;
@@ -664,7 +666,9 @@ export class PrismaLegacyModeExtension implements BuildExtension {
664666 commands . push (
665667 `${ binaryForRuntime (
666668 manifest . runtime
667- ) } node_modules/prisma/build/index.js generate ${ generatorFlags . join ( " " ) } ` // Don't add the --schema flag or this will fail
669+ ) } node_modules/prisma/build/index.js generate --schema=./prisma/schema ${ generatorFlags . join (
670+ " "
671+ ) } `
668672 ) ;
669673 } else {
670674 prismaDir = dirname ( this . _resolvedSchemaPath ) ;
0 commit comments