Ruby-on-rails rake db:migrate 似乎在生产中不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4909831/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 00:19:58  来源:igfitidea点击:

rake db:migrate doesn't seem to work in production

ruby-on-railsruby-on-rails-3

提问by Jason Swett

I have two instances of my app: one for development, one for production. My development database is called snip_developmentand my production database is called snip.

我的应用程序有两个实例:一个用于开发,一个用于生产。我的开发数据库被调用snip_development,我的生产数据库被调用snip

I've been doing migrations all along in my development environment and it's been going just fine. I recently created a production instance of my app but rake db:migratedoesn't seem to have any effect. After I run rake db:migrateand log into my database server, I can see that snip_developmenthas all the tables I expect it to but snipdoesn't have any tables at all.

我一直在我的开发环境中进行迁移,并且一切顺利。我最近创建了我的应用程序的生产实例,但rake db:migrate似乎没有任何效果。在我运行rake db:migrate并登录到我的数据库服务器后,我可以看到它snip_development拥有我期望的所有表,但snip根本没有任何表。

I suspect the problem is that rake db:migrateis running on snip_developmentinstead of snipand that's why I'm not seeing anything happen.

我怀疑问题在于它rake db:migrate正在运行snip_development而不是,snip这就是为什么我没有看到任何事情发生。

How do I get my migrations to work on my production database?

如何让我的迁移在我的生产数据库上工作?

回答by Jason Swett

Sometimes I forget about Google. The answer is this:

有时我会忘记谷歌。答案是这样的:

rake db:migrate RAILS_ENV=production

回答by yohanes

For me the answer above not works. I have to add bundle execto make it works.

对我来说,上面的答案不起作用。我必须添加bundle exec才能使其正常工作。

bundle exec rails db:migrate RAILS_ENV=production