fix(deploy): keep Prisma in the runtime image so migrations run with v6 - #465
Merged
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The Render deploy fails during the migration step:
Root cause
prismaand@prisma/clientwere both indevDependencies, sonpm prune --omit=devinDockerfile-backendstripped them from the runtime image. The barenpx prisma migrate deployinstartup.shthen downloaded the latest CLI (7.9.1) at deploy time, and Prisma 7 rejects this schema — it removedurlfrom datasource blocks and dropped themetricspreview feature.This also hid a second, more serious bug:
prismaClient.jsfalls back to a mock client when@prisma/clientis 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.jsdepends onprisma.$metrics.json(), which requires themetricspreview feature.Changes
package.json— moveprisma+@prisma/clienttodependenciesso they survive the prune (^6.19.3)package-lock.json— regenerated; only drops the"dev": trueflags, no version changesstartup.sh— invoke the bundled./node_modules/.bin/prismaand fail fast with a clear error if the CLI or client is missing, instead of silently installing a different major version.gitattributes— pin*.shto LF; a CRLF#!/bin/sh\rbakes into the image and fails with a confusing./startup.sh: not foundVerification
Tested with a real
Dockerfile-backendbuild against a live PostgreSQL container:node_modules/.bin/prismaand@prisma/clientboth absent after prune, reproducing the P1012 failureGET /health→200 {"status":"ok","database":"ok"}(real DB, no mock fallback)GET /metrics→200, pool monitor running with no "metrics unavailable" warningsNo Render configuration changes required.