如何在 Heroku 上使用 Ruby on Rails 项目从开发转向生产?
几个月来,我一直在学习 Ruby on Rails,同时制作我的第一个应用程序,现在它终于准备好开始被一些不幸的朋友用作 Beta 测试人员了。问题是,我不知道如何从开发转向生产。该应用程序位于 Heroku 上,到目前为止,每当我推送该应用程序时,我都会将本地开发数据库推送到 Heroku。
我知道我应该创建一个生产数据库来放置在 Heroku 上,但是我该怎么做呢?有地方指导吗?一旦生产数据库位于 Heroku 上,如果我需要在其上运行迁移,我该如何管理它?
感谢您的阅读
I've been learning Ruby on Rails whilst making my first app for a couple of months now, and it's finally ready to start to be used by a few unlucky friends as beta testers. Problem is, I have no idea as to how to move from development to production. The app is on Heroku, and up to this point I've just been pushing the local development database to Heroku whenever I push the app.
I know I'm supposed to create a production database to put on Heroku, but how do I do this? Is there a guide somewhere? How do I manage the production database once it's on Heroku, if I need to run migrations on it?
Thanks for reading
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
heroku db:reset - 删除所有现有数据
heroku rake db:migrate - 运行您的迁移。
heroku db:reset - remove all existing data
heroku rake db:migrate - Run your migrations.
如果您的迁移失败并且无法执行 Ian 建议的操作,您始终可以在本地构建一个裸露的初始生产数据库,然后将其推送到 Heroku。
db:push
可以使用参数来指定要推送的备用数据库。但在生产环境中管理数据库的方法是通过
heroku rake
和heroku console
。您几乎可以通过 rake 或控制台在本地执行任何操作。If your migrations are broken and you can't do what Ian suggested, you can always compose a bare initial production database locally and then push it up to Heroku.
db:push
can take an argument to specify an alternate database to push.But the way to manage the db on production is through
heroku rake
andheroku console
. You can do pretty much anything you'd do locally through rake or the console.另外值得注意的是,Heroku 会自动为您创建自己的用于生产的
database.yml
条目。无需将您自己的内容推送到他们的 git 存储库。Also worth noting that Heroku creates its own
database.yml
entries for production for you automatically. No need to push your own to their git repo.