Skip to content

fix(deploy): keep Prisma in the runtime image so migrations run with v6 - #465

Merged
Abdulazeem-code merged 1 commit into
mainfrom
fix/prisma-runtime-deps
Aug 3, 2026
Merged

fix(deploy): keep Prisma in the runtime image so migrations run with v6#465
Abdulazeem-code merged 1 commit into
mainfrom
fix/prisma-runtime-deps

Conversation

@Abdulazeem-code

Copy link
Copy Markdown
Owner

Problem

The Render deploy fails during the migration step:

Error: Prisma schema validation - (get-config wasm)
Error code: P1012
error: The datasource property `url` is no longer supported in schema files.
error: The preview feature "metrics" is not known.
Prisma CLI Version : 7.9.1
==> Exited with status 1

Root cause

prisma and @prisma/client were both in devDependencies, so npm prune --omit=dev in Dockerfile-backend stripped them from the runtime image. The bare npx prisma migrate deploy in startup.sh then downloaded the latest CLI (7.9.1) at deploy time, and Prisma 7 rejects this schema — it removed url from datasource blocks and dropped the metrics preview feature.

This also hid a second, more serious bug: prismaClient.js falls back to a mock client when @prisma/client is missing. Fixing only the migration step would have produced a container that starts "successfully" and silently serves fake data on every DB call.

Staying on Prisma 6 is the correct fix rather than migrating to 7 — src/db-pool-monitor.js depends on prisma.$metrics.json(), which requires the metrics preview feature.

Changes

  • package.json — move prisma + @prisma/client to dependencies so they survive the prune (^6.19.3)
  • package-lock.json — regenerated; only drops the "dev": true flags, no version changes
  • startup.sh — invoke the bundled ./node_modules/.bin/prisma and fail fast with a clear error if the CLI or client is missing, instead of silently installing a different major version
  • .gitattributes — pin *.sh to LF; a CRLF #!/bin/sh\r bakes into the image and fails with a confusing ./startup.sh: not found

Verification

Tested with a real Dockerfile-backend build against a live PostgreSQL container:

  • Original image: node_modules/.bin/prisma and @prisma/client both absent after prune, reproducing the P1012 failure
  • Fixed image: both present at 6.19.3; all 4 migrations apply; server boots on port 5000
  • GET /health200 {"status":"ok","database":"ok"} (real DB, no mock fallback)
  • GET /metrics200, pool monitor running with no "metrics unavailable" warnings
  • Guardrail confirmed: with the CLI removed, startup exits 1 with a clear message instead of downloading Prisma 7

No Render configuration changes required.

npm prune --omit=dev removed prisma and @prisma/client (both were
devDependencies) from the production image. npx prisma migrate deploy
then downloaded Prisma 7.9.1 at deploy time, which rejects this schema
(P1012: `url` in datasource block removed, `metrics` preview feature
dropped in v7), failing the deploy. The pruned runtime also fell back
to the mock PrismaClient and would have silently served fake data.

- Move prisma + @prisma/client to dependencies so they survive the prune
- Regenerate package-lock.json (drops the dev flags, no version changes)
- startup.sh: use ./node_modules/.bin/prisma and fail fast with a clear
  error if the CLI or client is missing, instead of downloading latest
- Add .gitattributes so *.sh keep LF and Docker images don't get a
  CRLF shebang (`./startup.sh: not found` on Linux)

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Aug 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
stellar-tags Ready Ready Preview Aug 3, 2026 12:48am

@Abdulazeem-code
Abdulazeem-code merged commit 23e15d0 into main Aug 3, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant