Rails 3.创建生产数据库

Sha*_*oke 31 ruby ruby-on-rails database-schema

如何在Rails 3中创建生产数据库并加载架构?

我尝试了以下方法......

一世.

rake db:create Rails.env='production' && rake db:schema:load Rails.env='production'
Run Code Online (Sandbox Code Playgroud)

II.

# config/environment.rb
# Set the rails environment
Rails.env='production'
rake db:create && rake db:schema:load
Run Code Online (Sandbox Code Playgroud)

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

谢谢.

Debian GNU/Linux 5.0.6;

Rails 3.0.0;

Sqlite3 3.7.2.

Mat*_*ggs 77

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

RAILS_ENV=production bundle exec rake db:create db:schema:load
Run Code Online (Sandbox Code Playgroud)

应该管用

  • 请注意不要破坏现有的数据库。如果你的模式有力量 => true 你可能会遇到糟糕的一天 (2认同)

Vic*_*r S 9

不应该这样

RAILS_ENV=production bundle exec rake db:create db:schema:load
Run Code Online (Sandbox Code Playgroud)