开发者

How to rollback database migration on Heroku

开发者 https://www.devze.com 2023-02-09 04:51 出处:网络
I just deployed some code and database changes to Heroku and I would like to roll it back. I do h开发者_C百科ave the releases add-on and was able to roll back the code but not the database. I didn\'t

I just deployed some code and database changes to Heroku and I would like to roll it back. I do h开发者_C百科ave 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 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 :)

0

精彩评论

暂无评论...
验证码 换一张
取 消