Following steps to go from v2 -> v3 and then ru...
# prisma-migrate
n
Following steps to go from v2 -> v3 and then running
prisma migrate dev
errored, but seems it is somewhat applied and now I have a drift scenario and a schema annotated with these new foreign keys etc. Is there command to rollback last migration on database? Been reading the docs and searching around. I can't lose this database. Worst case - thought is to export with mysql workbench or such and then take the platform offline and baseline / seed it with the backup maybe. But that is rough is will be a lot of time.
r
@Nick Foden 👋 Have you checked out this Upgrade Path for a change in 2.x to 3.x? There are some defaults that were set and now would be explicitly configured.
And it left me in a broken state where now I have to reset, but I can't lose my data.
1. updated to latest prisma 2.
npx prisma migrate dev
3. broken / half applied a migration and now have schema drift
so maybe I can export data with mysql workbench to later seed it back, but that isn't helpful if it will put back data in wrong shapes. So yeah I am thinking to try disaster recovery/backups from 24 hours ago and never go to version 3
r
Could you share the named constraints that you added?
n
Sorry for delay. Will do this today.
👍 1
d
Hey, @Nick Foden I know it's been a couple of months since you ran into the problem with a failed migration. But we've been hard at work at addressing situations like this. We now have two new commands to help you get out of such situations. Here is a guide how to use them. We'd love to get some feedback on that solution. https://www.prisma.io/docs/guides/database/production-troubleshooting#new-commands-migrate-diff-and-db-execute
n
Hey thanks for the follow up @do4gr . At the moment I am keeping our platform (mysql 8.0) on: •
"@prisma/client": "^2.30.3",
"prisma": "^2.30.3",
Because I can't risk having drift that ends up with us nuking everything again. That was miserable experience before and thankfully had low user activity that morning and we were able to roll back to a backup within an hour. This looks helpful
migrate diff
and will figure out a good time: • take platform offline • do full copy/backup • attempt migration
d
That makes sense. Hopefully with these new tools you have more control in these situations. Let us know once you were able to try it out