#Resolve failed prisma migrations

1 messages · Page 1 of 1 (latest)

opal hemlock
#

I'm experiencing an error while deploying my remix app to fly via github actions.
I recently altered one of my schemas, which led to the failed migration. I have deleted the migrations in the prisma/migrations folder and the local _prisma_migrations table and did a fresh prisma migrate dev. When I push to github I get an error that one of the migrations that I deleted could not be applied. How do I delete it completely in the production environment?

grave current
#

To rollback a production DB run:

npx prisma migrate diff --from-url "$DATABASE_URL_PROD" --to-migrations ./migrations --script > backward.sql

...which will create the SQL script needed for this next command:

npx prisma db execute --url "$DATABASE_URL_PROD" --file backward.sql

...which applies the changes to the DB without migrating. If you're happy with the changes run:

npx prisma migrate resolve --rolled-back <migration-name>
#

Not sure that will fix it but that's how to rollback a production db.

opal hemlock
#

Can I do a rollback if I have already deleted my migrations?
Now I have just one migration with the current state of my schema.

grave current
#

-Go to your fly dashboard and click on the db and go to "settings" and delete it.
-Then run flyctl postgres create -a <db-name> (make sure to get the url of the new production db and paste it in your .env file)
-Then run flyctl postgres attach <db-name>