Migration failed
What went wrong
Section titled “What went wrong”The app container exits or restarts repeatedly, and its logs end with:
ERROR: prisma migrate deploy failed; refusing to start.Why it happens
Section titled “Why it happens”On startup the app applies database migrations for the new version. If one fails, it stops rather than run against a half-changed database. Common causes:
- The database isn’t reachable, or
DATABASE_URLis wrong. - The database was changed by hand, so a migration conflicts with it.
- A previous migration was interrupted and is recorded as failed.
How to fix it
Section titled “How to fix it”- Read the lines before the error. Prisma names the migration and the database error.
- If the database is unreachable, check that the
dbcontainer is healthy (docker compose ps) and thatPOSTGRES_PASSWORDhasn’t changed since the database was created. - If a migration conflicts or failed half-way, go back to the previous version and restore your pre-upgrade backup, as described in Upgrading. Then report the error, with the logs, on GitHub.
Don’t edit the _prisma_migrations table unless you’re sure what the migration was meant to do.
See also
Section titled “See also”- Upgrading: back up before upgrading
- Backups and restore: restore a known-good database