bug: Prisma prismaSchemaFolder extension causes trigger.dev deploy to fail #1565
Description
Provide environment information
NextJS 14.2
@prisma/client@6.0.1
@trigger.dev/sdk": "3.3.7
Describe the bug
the build also fails if using prismaSchemaFolder extension.
If schema.prisma
`generator client {
provider = "prisma-client-js"
previewFeatures = ["postgresqlExtensions", "prismaSchemaFolder", "fullTextSearchPostgres"]
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
`
And then you create other.prisma and user.prisma.. everything works fine in NextJS.. however trigger.dev build says that schema.prisma is empty and errors out.
If all models are thrown into schema.prisma it works.
Tried including additional files in
import { defineConfig } from '@trigger.dev/sdk/v3';
import {
additionalPackages,
additionalFiles,
} from '@trigger.dev/build/extensions/core';
import { prismaExtension } from '@trigger.dev/build/extensions/prisma';
build: {
extensions: [
additionalFiles({
files: ['./prisma/schema/**'],
}),
prismaExtension({
schema: 'prisma/schema.prisma',
clientGenerator: 'client',
}),
additionalPackages({
packages: ['@prisma/client@6.0.1'],
}),
],
},
Reproduction repo
None
To reproduce
Set up prisma in nextjs with prismaSchemaFolder extension.
Create schema.prisma with no schemas
`generator client {
provider = "prisma-client-js"
previewFeatures = ["prismaSchemaFolder"]
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
`
Create user.prisma with schemas
`model User {
id String @id @unique
email String @unique
name String?
@@index([email])
}`
Set up trigger.config.ts
import { defineConfig } from '@trigger.dev/sdk/v3';
import {
additionalPackages,
additionalFiles,
} from '@trigger.dev/build/extensions/core';
import { prismaExtension } from '@trigger.dev/build/extensions/prisma';
build: {
extensions: [
additionalFiles({
files: ['./prisma/schema/**'],
}),
prismaExtension({
schema: 'prisma/schema.prisma',
clientGenerator: 'client',
}),
additionalPackages({
packages: ['@prisma/client@6.0.1'],
}),
],
},
Trigger.dev fails to deploy. With or without additionalFiles. It does not seem to load in the extension.
Error is simply that there are no models in the schema.prisma
If all models are thrown into schema.prisma it works.
Additional information
No response
Activity
ericallam commentedon Dec 14, 2024
@RobertHH-IS This definitely should work, and I haven't been able to replicate this. Do you think you could publish an actual repo on GitHub that reproduces this issue? That would be extremely helpful if so 🫡
RobertHH-IS commentedon Dec 15, 2024
Certainly:
https://github.com/RobertHH-IS/trigger-prismafolder
when following the step
pnpm dlx trigger.dev@latest deploy
I get error
i tried it with and without the additionalFiles extension
ericallam commentedon Dec 15, 2024
@RobertHH-IS thanks for the reproduction, I've been able to track down what is going on here. Apparently when using the
prismaSchemaFolderpreview feature, you have to switch to no longer passing the schema file to CLI commands, and update it to passing the schema dir:In the package.json of this project you are actually doing that correctly, but the prisma CLI will actually use the setting in the package.json if it exists (and the
--schemaflag isn't passed into the prisma CLI command):The
trigger.dev deploycommand was copying that prisma configuration from your package.json to the container, but it wasn't passing a--schemaflag to thegeneratecommand pointing to the schema dir. We could fix this on our end by making sure that--schemaflag is always passed, but in the meantime, simply changing the package.json to this will fix the problem:Also, there's no need to use the
additionalFilesextension, as we will already detect using multiple .prisma files and copy them into the deployed image.RobertHH-IS commentedon Dec 15, 2024
Correct - working now :-)
Thanks!