
20 November 2026 · 2 min read
A Deploy That Failed Safely Three Times
I found this while doing a routine pass over what was left to do, not because anything alerted me: the production deploy workflow had failed three times in a row.
The error#
The datasource.url property is required in your Prisma config file when using prisma migrate deploy.
Prisma 7 moved the database URL out of schema.prisma and into a prisma.config.ts file. The Dockerfile's final stage copied the prisma directory, with the schema, but never copied the config file. So the deploy step that runs prisma migrate deploy inside the image had a schema and no datasource.
Why production never noticed#
The deploy script runs with set -e. When the migration step failed, the script stopped before the step that swaps the running container. The old container, from before the upgrade, kept serving traffic through all three attempts. New code just could not land.
That is a failure mode worth designing for on purpose: when something goes wrong halfway, the system should stay in its last known good state. Here it did, by the luck of one shell option rather than a plan, and I would rather it were a plan.
The fix, and how I checked it#
One line: copy prisma.config.ts into the runner stage. I could not build the image in the environment I was working in, so I reproduced the failure a different way. Removing the config file locally and running the migrate command gave the identical error. Putting it back changed the error to P1001, can't reach database, which is what you expect with no database available: Prisma had loaded the datasource URL from the config. After the merge, the next deploy succeeded and the health endpoint answered with a real database round trip.
The lesson#
A build succeeding in the builder stage says nothing about whether the final stage has everything the container needs to run its own commands later. Migrations and scripts are runtime dependencies too. Back then no CI job exercised the image or the deploy script, so nothing could have caught this before production did. The pipeline now has jobs named for exactly that: an image smoke test and a deploy script check.