Rails 3和Heroku:自动“rake db:migrate”推? [英] Rails 3 and Heroku: automatically "rake db:migrate" on push?

查看:124
本文介绍了Rails 3和Heroku:自动“rake db:migrate”推?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对我的heroku推送/部署过程有一些轻微的烦恼,否则这个过程很快就会被发现和使用。

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



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

这是我在一个heroku cpanel中设置的东西吗?这是我从命令行传递给heroku的选项吗?它是一个混帐钩子?任何人都可以设置我吗?谢谢,max

解决方案

这是一个将所有内容都包装为单行(并支持回滚)的rake任务: / p>

https://gist.github.com/362873



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


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

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.

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.

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

解决方案

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

https://gist.github.com/362873

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”推?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆