开发者

How to rollback database migration on Heroku

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜