问题描述
我的应用有两个实例:一个用于开发,一个用于生产.我的开发数据库名为 snip_development
,我的生产数据库名为 snip
.
I have two instances of my app: one for development, one for production. My development database is called snip_development
and my production database is called snip
.
我一直在我的开发环境中进行迁移,并且一切顺利.我最近创建了我的应用程序的生产实例,但 rake db:migrate
似乎没有任何效果.在我运行 rake db:migrate
并登录到我的数据库服务器后,我可以看到 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:migrate
doesn't seem to have any effect. After I run rake db:migrate
and log into my database server, I can see that snip_development
has all the tables I expect it to but snip
doesn't have any tables at all.
我怀疑问题在于 rake db:migrate
在 snip_development
而不是 snip
上运行,这就是为什么我没有看到任何东西发生.
I suspect the problem is that rake db:migrate
is running on snip_development
instead of snip
and that's why I'm not seeing anything happen.
如何让我的迁移在我的生产数据库上工作?
How do I get my migrations to work on my production database?
推荐答案
有时我会忘记 Google.答案是这样的:
Sometimes I forget about Google. The answer is this:
rake db:migrate RAILS_ENV=production
这篇关于rake db:migrate 似乎在生产中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!