We seem to have gotten our prisma migrations into a bad state. When we get the latest code and run
prisma migrate dev
we get
Migration
20210819161149_some_migration
failed to apply cleanly to the shadow database. Error code: P3018 Error: A migration failed to apply. New migrations cannot be applied before the error is recovered from. Read more about how to resolve migration issues in a production database: https://pris.ly/d/migrate-resolveMigration name: 20210819161149_some_migration
Database error code: 1065
All the migrations in source control do match the ones in the _prisma_migrations
table so I'm not sure why it thinks 20210819161149_some_migration
failed. There is nothing in the logs
column in _prisma_migrations
for that record. I think what happened is a developer applied the migration then changed the migration.sql
for it after the fact.
Anyway, we followed the steps outlined https://pris.ly/d/migrate-resolve but they don't seem to resolve the issue. It first suggests running
prisma migrate resolve --rolled-back "20210819161149_some_migration"
but that results in
Error: P3012
Migration
20210819161149_some_migration
cannot be rolled back because it is not in a failed state.
So then we tried to mark it as applied
prisma migrate resolve --applied "20210819161149_some_migration"
but that results in this error
Error: P3008
The migration
20210819161149_some_migration
is already recorded as applied in the database.
We also tried running
prisma migrate deploy
Which gives
13 migrations found in prisma/migrations WARNING The following migrations have been modified since they were applied: 20210819161149_some_migration
but you still get the same issue above when running prisma migrate dev
.
Is there any way to get prisma happy again without deleting all the data?
prisma format
i think will help you! – Steckprisma format
is not relevant or helpful at all for this question. – Engulf