Rails 3 和 Heroku:自动“rake db:migrate"推?

编程入门 行业动态 更新时间:2024-10-28 15:22:16
本文介绍了Rails 3 和 Heroku:自动“rake db:migrate"推?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我对我的 heroku 推送/部署过程有点不满,否则发现和使用它是一种乐趣.

I have a slight annoyance with my heroku push/deploy process, which otherwise has been a joy to discover and use.

如果我向我的应用程序添加一个新的迁移,我可以将它放到 heroku 服务器上的唯一方法是推送到 heroku 远程.这会上传它并重新启动应用程序.但它不运行迁移,所以我必须执行 heroku rake db:migrate --app myapp,然后 heroku restart --app myapp.与此同时,该应用程序已损坏,因为它尚未运行迁移,并且代码在迁移中引用了字段/表等.

If i add a new migration to my app, the only way i can get it up onto the heroku server is to do a push to the heroku remote. This uploads it and restarts the app. But it doesn't run the migration, so i have to do heroku rake db:migrate --app myapp, then heroku restart --app myapp. In the meantime, the app is broken because it hasn't run the migrations and the code is referring to fields/tables etc in the migration.

必须有一种方法来更改部署过程以自动运行 rake db:migrate 作为部署过程的一部分,但我无法解决.

There must be a way to change the deployment process to run the rake db:migrate automatically as part of the deploy process but i can't work it out.

这是我在 heroku cpanel 中设置的吗?这是我从命令行传递给 heroku 的一个选项吗?它是一个 git 钩子吗?谁能让我直截了当?谢谢,最大

Is it something i set in a heroku cpanel? Is it an option i pass to heroku from the command line? Is it a git hook? Can anyone set me straight? thanks, max

推荐答案

这里有一个 rake 任务,它把所有东西都打包成一个单行(并且还支持回滚):

Here is a rake task that wraps up everything into a one-liner (and also supports rollback):

gist.github/362873

您仍然可能会在老板的演示之上进行部署,但至少您不会浪费时间在 git push 和 rake db:migrate 之间打字.

You still might wind up deploying on top of your boss's demo, but at least you don't waste time typing between the git push and the rake db:migrate.

更多推荐

Rails 3 和 Heroku:自动“rake db:migrate"推?

本文发布于:2023-10-22 20:54:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1518685.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:rake   Heroku   Rails   quot   migrate

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!