Ruby-on-rails Rails 3. 创建生产数据库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3690121/
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-02 23:12:11  来源:igfitidea点击:

Rails 3. Creating a production database

ruby-on-railsrubydatabase-schema

提问by Shamaoke

How can I create a production database in Rails 3 and load a schema to it?

如何在 Rails 3 中创建生产数据库并向其加载模式?

I tried the following approaches...

我尝试了以下方法...

I.

一世。

rake db:create Rails.env='production' && rake db:schema:load Rails.env='production'

II.

二、

# config/environment.rb
# Set the rails environment
Rails.env='production'
rake db:create && rake db:schema:load

... but neither of them works.

......但它们都不起作用。

Thanks.

谢谢。

Debian GNU/Linux 5.0.6;

Debian GNU/Linux 5.0.6;

Rails 3.0.0;

导轨 3.0.0;

Sqlite3 3.7.2.

Sqlite3 3.7.2。

回答by Matt Briggs

You can set the rails env off of the environment variable RAILS_ENV

您可以将 rails env 设置为环境变量 RAILS_ENV

RAILS_ENV=production bundle exec rake db:create db:schema:load

should work

应该管用

回答by Victor S

Shouldn't this be

这不应该是

RAILS_ENV=production bundle exec rake db:create db:schema:load