Prisma "P3009: migrate found failed migrations in the target database" in CI
P3009 means the _prisma_migrations table records a migration that started but did not finish. To avoid applying migrations on top of a broken state, migrate deploy stops until you resolve the failed entry.
What this error means
migrate deploy fails immediately with "P3009: migrate found failed migrations in the target database" and names the migration that is marked failed.
Error: P3009 migrate found failed migrations in the target database, new migrations will not be applied.
The `20260601120000_add_orders` migration started at ... failedCommon causes
A previous migration failed partway
An earlier deploy applied part of a migration then failed, leaving a failed record that blocks further migrations.
A shared database left in a bad state
A prior job or environment failed a migration on the same database, and later jobs inherit the blocked state.
How to fix it
Resolve the failed migration
- Inspect what the failed migration did to the schema.
- Mark it rolled-back or applied with
prisma migrate resolve. - Re-run
prisma migrate deploy.
npx prisma migrate resolve --rolled-back 20260601120000_add_orders
npx prisma migrate deployReset a disposable CI database
If the database is ephemeral in CI, resetting it clears the failed state so migrations apply from scratch.
npx prisma migrate reset --forceHow to prevent it
- Make CI migrations idempotent and test them before merge.
- Use a fresh ephemeral database per CI run where possible.
- Resolve failed migrations promptly so shared DBs are not blocked.