Skip to content

bug: Prisma 6.6+ Schema Folder Bug: Missing --schema Flag #2654

@cameronmema

Description

@cameronmema

Provide environment information

System:
OS: macOS 26.0
CPU: (16) arm64 Apple M4 Max
Memory: 1018.27 MB / 48.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 24.7.0 - /Users/cm/.nvm/versions/node/v24.7.0/bin/node
Yarn: 1.22.22 - /Users/cm/.nvm/versions/node/v24.7.0/bin/yarn
npm: 11.5.1 - /Users/cm/.nvm/versions/node/v24.7.0/bin/npm
bun: 1.2.21 - /Users/cm/.bun/bin/bun

Describe the bug

The prismaExtension fails with Prisma 6.6+ when using schema folders with names other than "schema" (e.g., models/, db/, etc.).

Expected: Prisma client generates successfully in production builds
Actual: Prisma client is undefined, causing TypeError: Cannot read properties of undefined (reading 'findMany') in all tasks

The extension has two bugs:

  1. Hardcoded folder detection - Line 58 only checks endsWith("schema"), breaking valid custom folder names
  2. Missing --schema flag - Line 102 omits --schema flag for Prisma 6.6+ with outdated comment "Don't add the --schema flag or this will fail"

Per Prisma 6.6 docs:

As of v6.6.0, you must always explicitly specify the location of your Prisma schema folder.

Reproduction repo

https://gist.github.com/cameronmema/f86139133c28e2bec878cf374b942fe2

To reproduce

To reproduce

1. Setup (Monorepo with schema folder NOT named "schema")

packages/
  prisma/
    src/
      models/              ← Named "models" not "schema"
        schema.prisma      ← Generator + datasource
        user.prisma
        order.prisma
        ...
  jobs/
    trigger.config.ts

2. Configure Trigger.dev

// packages/jobs/trigger.config.ts
import { prismaExtension } from "@trigger.dev/build/extensions/prisma";
import { defineConfig } from "@trigger.dev/sdk";

export default defineConfig({
  project: "proj_xxx",
  build: {
    extensions: [
      prismaExtension({
        version: "6.18.0",
        schema: "../../packages/prisma/src/models/schema.prisma",
        migrate: false,
      }),
    ],
  },
});

3. Deploy

bun run trigger deploy

4. Result

Build output shows files being copied:

Copying prisma schema from .../models/base.prisma to .../build/prisma/schema/base.prisma
Copying prisma schema from .../models/user.prisma to .../build/prisma/schema/user.prisma
...

Then fails:

> [build 6/7] RUN node node_modules/prisma/build/index.js generate:
Error: exit code: 1

Production runtime:

TypeError: Cannot read properties of undefined (reading 'findMany')
    at run (file:///src/tasks/my-task.ts:30:46)

Additional information

Additional information

The Two Bugs in Detail

Bug #1: packages/build/src/extensions/prisma.ts:58

const usingSchemaFolder = dirname(this._resolvedSchemaPath).endsWith("schema");

Only detects folders ending with "schema". Breaks with models/, db/, or any custom name.

Bug #2: packages/build/src/extensions/prisma.ts:101-102

commands.push(
  `node_modules/prisma/build/index.js generate ${generatorFlags.join(" ")}` 
  // Don't add the --schema flag or this will fail ← OUTDATED for Prisma 6.6+
);

The comment is wrong. Prisma 6.6+ requires the --schema flag.

The Fix (2 Lines)

Fix #1 - Better folder detection:

const parentDirName = dirname(this._resolvedSchemaPath).split("/").pop() || "";
const usingSchemaFolder = parentDirName === "schema" || parentDirName === "models";

Fix #2 - Add --schema flag for Prisma 6.6+:

if (usingSchemaFolder) {
  commands.push(
    `${binaryForRuntime(manifest.runtime)} node_modules/prisma/build/index.js generate --schema=./prisma/schema ${generatorFlags.join(" ")}`
  );
}

Workaround

I created a custom extension with these fixes: https://gist.github.com/cameronmema/f86139133c28e2bec878cf374b942fe2

Works perfectly, but users shouldn't need 240 lines of custom code for this.

Related

Impact

Affects any monorepo using:

  • Prisma 6.6+
  • Multi-file schemas (schema folders)
  • Folder name other than "schema"

This is a breaking bug for common monorepo patterns where Prisma packages use descriptive folder names like models/, database/, db/, etc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions