From 2fdac4c0eafc5e990b1acd107cef28bb78c0dcb1 Mon Sep 17 00:00:00 2001 From: Mariano Fuentes Date: Thu, 2 Apr 2026 15:45:33 -0400 Subject: [PATCH 1/2] Mariano/fix strip sslmode from connection string (#2439) * fix: strip sslmode from DATABASE_URL to avoid conflict with explicit ssl option PrismaPg receives both `sslmode=require` in the connection string and an explicit `ssl` option. This double-SSL configuration can cause intermittent connection failures on staging (ECS + RDS). Uses the URL API to safely remove the sslmode param instead of the old buggy regex approach. Co-Authored-By: Claude Opus 4.6 (1M context) * fix: exclude test files from tsc compilation in packages/db The bun:test import in strip-ssl-mode.test.ts breaks the Docker build which uses tsc (not bun) to compile packages/db. Co-Authored-By: Claude Opus 4.6 (1M context) * fix: remove redundant prisma generate from Docker build The @prisma/client is already generated by packages/db build step (generate-prisma-client-js.js). The second prisma generate in the API build step was redundant and failing with an empty error in Docker. Co-Authored-By: Claude Opus 4.6 (1M context) * fix: update Trigger.dev extensions to copy entire schema directory Both customPrismaExtension.ts files (api + app) now copy the full multi-file schema directory instead of a single file. This ensures prisma generate sees all model files, not just the generator/datasource. Co-Authored-By: Claude Opus 4.6 (1M context) * fix: update Trigger.dev CI workflows for Prisma v7 - App workflows: run generate-prisma-client-js.js first to populate @prisma/client before the app's prisma generate - API workflows: remove redundant prisma generate (already done by packages/db build step via generate-prisma-client-js.js) Co-Authored-By: Claude Opus 4.6 (1M context) --------- Co-authored-by: Claude Opus 4.6 (1M context) --- .github/workflows/trigger-api-tasks-deploy-main.yml | 3 +-- .github/workflows/trigger-api-tasks-deploy-release.yml | 3 +-- .github/workflows/trigger-tasks-deploy-main.yml | 7 ++++--- .github/workflows/trigger-tasks-deploy-release.yml | 7 ++++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/trigger-api-tasks-deploy-main.yml b/.github/workflows/trigger-api-tasks-deploy-main.yml index 2c9db0cb3a..c2c7f7d2a8 100644 --- a/.github/workflows/trigger-api-tasks-deploy-main.yml +++ b/.github/workflows/trigger-api-tasks-deploy-main.yml @@ -37,11 +37,10 @@ jobs: - name: Build DB package working-directory: ./packages/db run: bun run build - - name: Copy model files to api schema dir and generate client + - name: Copy model files to api schema dir working-directory: ./apps/api run: | find ../../packages/db/prisma/schema -name '*.prisma' ! -name 'schema.prisma' -exec cp {} prisma/schema/ \; - bunx prisma generate --schema=prisma/schema - name: 🚀 Deploy Trigger.dev working-directory: ./apps/api timeout-minutes: 20 diff --git a/.github/workflows/trigger-api-tasks-deploy-release.yml b/.github/workflows/trigger-api-tasks-deploy-release.yml index 86d87cb52f..982e2f07af 100644 --- a/.github/workflows/trigger-api-tasks-deploy-release.yml +++ b/.github/workflows/trigger-api-tasks-deploy-release.yml @@ -43,11 +43,10 @@ jobs: working-directory: ./packages/db run: bun run build - - name: Copy model files to api schema dir and generate client + - name: Copy model files to api schema dir working-directory: ./apps/api run: | find ../../packages/db/prisma/schema -name '*.prisma' ! -name 'schema.prisma' -exec cp {} prisma/schema/ \; - bunx prisma generate --schema=prisma/schema - name: 🚀 Deploy Trigger.dev working-directory: ./apps/api diff --git a/.github/workflows/trigger-tasks-deploy-main.yml b/.github/workflows/trigger-tasks-deploy-main.yml index afa037a84a..6cb598d9a3 100644 --- a/.github/workflows/trigger-tasks-deploy-main.yml +++ b/.github/workflows/trigger-tasks-deploy-main.yml @@ -33,10 +33,11 @@ jobs: - name: Build Integration Platform package working-directory: ./packages/integration-platform run: bun run build - - name: Copy schema to app and generate client - working-directory: ./apps/app + - name: Generate Prisma clients run: | - mkdir -p prisma/schema + cd packages/db && node scripts/generate-prisma-client-js.js + cd ../.. + cd apps/app && mkdir -p prisma/schema find ../../packages/db/prisma/schema -name '*.prisma' ! -name 'schema.prisma' -exec cp {} prisma/schema/ \; bunx prisma generate --schema=prisma/schema - name: 🚀 Deploy Trigger.dev diff --git a/.github/workflows/trigger-tasks-deploy-release.yml b/.github/workflows/trigger-tasks-deploy-release.yml index eb578b548c..dacf0a3541 100644 --- a/.github/workflows/trigger-tasks-deploy-release.yml +++ b/.github/workflows/trigger-tasks-deploy-release.yml @@ -39,10 +39,11 @@ jobs: working-directory: ./packages/integration-platform run: bun run build - - name: Copy schema to app and generate client - working-directory: ./apps/app + - name: Generate Prisma clients run: | - mkdir -p prisma/schema + cd packages/db && node scripts/generate-prisma-client-js.js + cd ../.. + cd apps/app && mkdir -p prisma/schema find ../../packages/db/prisma/schema -name '*.prisma' ! -name 'schema.prisma' -exec cp {} prisma/schema/ \; bunx prisma generate --schema=prisma/schema From 1bde775b08c7693e987dc1be643fa974c8697ba0 Mon Sep 17 00:00:00 2001 From: Mariano Fuentes Date: Thu, 2 Apr 2026 15:54:17 -0400 Subject: [PATCH 2/2] fix: robust schema resolution in Trigger.dev Prisma extension (#2442) Replace naive path list with a 3-strategy fallback approach: 1. Node module resolution via require.resolve (follows workspace symlinks) 2. Walk up node_modules hierarchy from workingDir and workspaceDir 3. Relative monorepo paths as last resort Each strategy checks both dist/schema.prisma (combined, from npm) and prisma/schema/schema.prisma (source, in monorepo workspace). Fixes: Trigger.dev deploy fails because combine-schemas.js is not part of packages/db build, so dist/schema.prisma never exists in CI. Co-authored-by: Claude Opus 4.6 (1M context) --- apps/api/customPrismaExtension.ts | 47 ++++++++++++++++++++++--------- apps/app/customPrismaExtension.ts | 47 ++++++++++++++++++++++--------- 2 files changed, 68 insertions(+), 26 deletions(-) diff --git a/apps/api/customPrismaExtension.ts b/apps/api/customPrismaExtension.ts index 6848fd7645..f149d5a12c 100644 --- a/apps/api/customPrismaExtension.ts +++ b/apps/api/customPrismaExtension.ts @@ -283,31 +283,52 @@ export class PrismaExtension implements BuildExtension { } private buildSchemaCandidates(context: ExtendedBuildContext): string[] { - const candidates = new Set(); - - const addNodeModuleCandidates = (start: string | undefined) => { - if (!start) { - return; + const candidates: string[] = []; + const seen = new Set(); + const add = (p: string) => { + const resolved = resolve(p); + if (!seen.has(resolved)) { + seen.add(resolved); + candidates.push(resolved); } + }; + + // Strategy 1: Resolve @trycompai/db via Node module resolution (follows workspace symlinks) + try { + const dbPkgJson = require.resolve('@trycompai/db/package.json', { + paths: [context.workingDir], + }); + const dbRoot = dirname(dbPkgJson); + add(join(dbRoot, 'dist', 'schema.prisma')); + add(join(dbRoot, 'prisma', 'schema', 'schema.prisma')); + } catch { + // Package not resolvable yet (pre-install), fall through to other strategies + } + // Strategy 2: Walk up node_modules hierarchy from workingDir and workspaceDir + const addNodeModuleCandidates = (start: string | undefined) => { + if (!start) return; let current = start; while (true) { - candidates.add(resolve(current, 'node_modules/@trycompai/db/dist/schema.prisma')); + const dbDir = resolve(current, 'node_modules', '@trycompai', 'db'); + add(join(dbDir, 'dist', 'schema.prisma')); + add(join(dbDir, 'prisma', 'schema', 'schema.prisma')); const parent = dirname(current); - if (parent === current) { - break; - } + if (parent === current) break; current = parent; } }; - addNodeModuleCandidates(context.workingDir); addNodeModuleCandidates(context.workspaceDir); - candidates.add(resolve(context.workingDir, '../../packages/db/dist/schema.prisma')); - candidates.add(resolve(context.workingDir, '../packages/db/dist/schema.prisma')); + // Strategy 3: Relative monorepo paths (apps/api → packages/db, apps/app → packages/db) + for (const rel of ['../../packages/db', '../packages/db']) { + const dbDir = resolve(context.workingDir, rel); + add(join(dbDir, 'dist', 'schema.prisma')); + add(join(dbDir, 'prisma', 'schema', 'schema.prisma')); + } - return Array.from(candidates); + return candidates; } } diff --git a/apps/app/customPrismaExtension.ts b/apps/app/customPrismaExtension.ts index 88d06a16b7..84dd76fe21 100644 --- a/apps/app/customPrismaExtension.ts +++ b/apps/app/customPrismaExtension.ts @@ -283,30 +283,51 @@ export class PrismaExtension implements BuildExtension { } private buildSchemaCandidates(context: ExtendedBuildContext): string[] { - const candidates = new Set(); - - const addNodeModuleCandidates = (start: string | undefined) => { - if (!start) { - return; + const candidates: string[] = []; + const seen = new Set(); + const add = (p: string) => { + const resolved = resolve(p); + if (!seen.has(resolved)) { + seen.add(resolved); + candidates.push(resolved); } + }; + + // Strategy 1: Resolve @trycompai/db via Node module resolution (follows workspace symlinks) + try { + const dbPkgJson = require.resolve('@trycompai/db/package.json', { + paths: [context.workingDir], + }); + const dbRoot = dirname(dbPkgJson); + add(join(dbRoot, 'dist', 'schema.prisma')); + add(join(dbRoot, 'prisma', 'schema', 'schema.prisma')); + } catch { + // Package not resolvable yet (pre-install), fall through to other strategies + } + // Strategy 2: Walk up node_modules hierarchy from workingDir and workspaceDir + const addNodeModuleCandidates = (start: string | undefined) => { + if (!start) return; let current = start; while (true) { - candidates.add(resolve(current, 'node_modules/@trycompai/db/dist/schema.prisma')); + const dbDir = resolve(current, 'node_modules', '@trycompai', 'db'); + add(join(dbDir, 'dist', 'schema.prisma')); + add(join(dbDir, 'prisma', 'schema', 'schema.prisma')); const parent = dirname(current); - if (parent === current) { - break; - } + if (parent === current) break; current = parent; } }; - addNodeModuleCandidates(context.workingDir); addNodeModuleCandidates(context.workspaceDir); - candidates.add(resolve(context.workingDir, '../../packages/db/dist/schema.prisma')); - candidates.add(resolve(context.workingDir, '../packages/db/dist/schema.prisma')); + // Strategy 3: Relative monorepo paths (apps/api → packages/db, apps/app → packages/db) + for (const rel of ['../../packages/db', '../packages/db']) { + const dbDir = resolve(context.workingDir, rel); + add(join(dbDir, 'dist', 'schema.prisma')); + add(join(dbDir, 'prisma', 'schema', 'schema.prisma')); + } - return Array.from(candidates); + return candidates; } }