如何在 Heroku 上回滚数据库迁移
我刚刚向 Heroku 部署了一些代码和数据库更改,我想将其回滚。我确实有版本附加组件,并且能够回滚代码,但不能回滚数据库。我没有备份数据库,所以无法进行恢复。我尝试了“heroku rake db:rollback”,但它没有做任何事情。有人知道吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须运行
heroku rake db:rollback
,同时将具有.down
迁移的更新代码部署到 Heroku。之后,您可以回滚代码。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 将回滚最后执行的迁移文件 - 您确定这还没有执行吗?如果您能够确定要为部署回滚的迁移数量,您可以
在最近 3 次迁移中运行 down 方法 - 当然,如果您已对向下迁移进行编码以准确恢复原来的内容,则 可以这样做在向上迁移中完成:)
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
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 :)