Ruby-on-rails Production database not created by rake db:create command

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

Production database not created by rake db:create command

ruby-on-rails

提问by Joe

Im a Rails beginner and am using Rails 3 on Ubuntu 10.10. My database.yml is as follows.

Im a Rails beginner and am using Rails 3 on Ubuntu 10.10. My database.yml is as follows.

development:
  adapter: mysql
  database: project_dev
  username: root
  password: rootpassword
  host: localhost

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: mysql
  database: project_test
  username: root
  password: rootpassword
  host: localhost

production:
  adapter: mysql
  database: project_production
  username: root
  password: rootpassword
  host: localhost

Then i switched to the project folder and ran the command:

Then i switched to the project folder and ran the command:

rake db:create

But,only the project_dev and project_test databases were created. The project_production database did not exist in mysql. What could the problem here ?

But,only the project_dev and project_test databases were created. The project_production database did not exist in mysql. What could the problem here ?

Please Help Thank You

Please Help Thank You

回答by iain

That is the way it is intended to be. To create the production database do:

That is the way it is intended to be. To create the production database do:

RAILS_ENV=production rake db:create

Also, have a look at rake db:setupwhich will run anything you put in db/seeds.rb.

Also, have a look at rake db:setupwhich will run anything you put in db/seeds.rb.

回答by noodl

This is by design as @iain suggests. To create all databases, run rake db:create:all.

This is by design as @iain suggests. To create all databases, run rake db:create:all.