I just deployed some code and database changes to Heroku and I would like to roll it back. I do have the releases add-on and was able to roll back the code but not the database. I didn't backup the database so I can't do a restore. I tried "heroku rake db:rollback" but it didn't do anything. Anyone knows?
You can use db:migrate:undo , this command will revert the most recent migration. You can revert back to the initial state by undoing all migrations with the db:migrate:undo:all command.
To check for status, run rails db:migrate:status . Then you'll have a good view of the migrations you want to remove. Then, run rails db:rollback to revert the changes one by one. After doing so, you can check the status again to be fully confident.
You have to run heroku rake db:rollback
while the updated code that has the .down
migration is deployed to Heroku. After that, you can rollback the code.
db:rollback will rollback the last migration file that was executed - are you sure this hasn't been performed? If you're able to identify the number of migrations that you want to rollback for your deployment you can do
rake db:rollback STEP=3
which runs the down method in your last 3 migrations - this is of course if you've coded the down migration to revert exactly what was done in the up migration :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With