Help with Prisma migrations in prod #540
-
I accidentally broke a migration in prod that worked okay in dev because I didn't have conflicting data in dev. The migration was flagged as failed in the prod DB, then I fixed the schema, created another migration, and deployed the app but still got the same error that no new migrations will be applied. I tried to deploy an older version of the app that didn't have this said migration but that deployment failed too saying that no new migrations will be applied. The fly app machine is offline, so I cannot connect to it and follow the steps from Prisma docs. I don't think deleting the migration generated by Prisma would help because that migration is flagged as failed in prod DB. Any help is appreciated, thanks you migrate found failed migrations in the target database, new migrations will not be applied. Read more about how to resolve migration issues in a production database: https://pris.ly/d/migrate-resolve |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
Dang, I'm not sure what the best course of action would be in this scenario. The first thing I would try is to make it so my app can start up so I can download the database and back it up (especially if you don't have the LiteFS cloud backups enabled). From there you could actually fix it all locally and then upload it and maybe your job would be done. To get the app started, you could deploy a temporary app that's just a simple node server that passes health checks (like a hello world express app would be enough). Once it's up and running, then you should be able to get in there and do stuff. There's probably a better way to look into a volume when the app's not running, but I'm unaware of what that might be. |
Beta Was this translation helpful? Give feedback.
-
I've been in this exact spot before, I was fortunate that I was still in development and none of the data on my app was real data. So i ended up deleting the app and recreating the app with the same name. Not sure if this is applicable for you or if you need the data in your app. Its really annoying and there has gotta be a way to start the instance and skip running migrations or just don't run a start command. All I needed was the instance running so I could ssh into it and fix it. I just wasn't able to figure it out. |
Beta Was this translation helpful? Give feedback.
-
This is how I fixed it: TLDR: Steps:
Note: steps 6 to 9 can be omitted by running SQL to remove the problematic entry from |
Beta Was this translation helpful? Give feedback.
This is how I fixed it:
TLDR:
Run the app without exec section in
litefs.yml
file and then re-deploy the app. Remove the problematic prisma migration from the prod db and migration SQL file. Re deploy the app with the exec section inlitefs.yml
file.Steps:
litefs.yml
_prisma_migrations
table from the copied dblitefs.yml