Rake db:create (in development mode) creates development _and_ test database

This behaviour seems strange to me:

Rails 3.0.4

$ rake db:create

=> creates project_dev AND project_test databases

$ rake db:drop

=> only drops the project_dev database (as expected)

$ RAILS_ENV=test rake db:drop

=> this effectively drops the project_test database (as expected)

Seems in conflict with this description:

$ rake -T db:create
rake db:create # Create the database from config/database.yml for the
current Rails.env
(use db:create:all to create all dbs i…

$ rake -T db:drop
rake db:drop # Drops the database for the current Rails.env
(use db:drop:all to drop all databases)

If this is not the intended behaviour, I can submit a bug report in
rails-core and probably work up a patch too. Catting my Gemfile here
(just did bundle update with this):

$ cat Gemfile
source ‘http://rubygems.org

gem ‘rails’, ‘3.0.4’
gem ‘pg’, ‘0.10.1’
gem ‘capistrano’
gem ‘openminds_deploy’

group :development, :test do
gem ‘rspec-rails’, ‘>= 2.0.0’
gem ‘cucumber-rails’, ‘>= 0.3.2’
gem ‘webrat’, ‘>= 0.7.2’
gem ‘autotest’
end

HTH,

Peter

I guess the document for db:create need to be updated:

activerecord/lib/active_record/railties/databases.rake#36

desc ‘Create the database from config/database.yml for the current
Rails.env (use db:create:all to create all dbs in the config)’
task :create => :load_config do
# Make the test database at the same time as the development one, if
it
exists
if Rails.env.development? &&
ActiveRecord::Base.configurations[‘test’]
create_database(ActiveRecord::Base.configurations[‘test’])
end
create_database(ActiveRecord::Base.configurations[Rails.env])
end

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs