diff --git a/activerecord/lib/active_record/tasks/database_tasks.rb b/activerecord/lib/active_record/tasks/database_tasks.rb index 0883e80d23..d8e0cd1e30 100644 --- a/activerecord/lib/active_record/tasks/database_tasks.rb +++ b/activerecord/lib/active_record/tasks/database_tasks.rb @@ -315,12 +315,16 @@ module ActiveRecord environments << "test" if environment == "development" ActiveRecord::Base.configurations.slice(*environments).each do |configuration_environment, configuration| + next unless configuration["database"] + yield configuration, configuration_environment end end def each_local_configuration ActiveRecord::Base.configurations.each_value do |configuration| + next unless configuration["database"] + if local_database?(configuration) yield configuration else diff --git a/activerecord/test/cases/tasks/database_tasks_test.rb b/activerecord/test/cases/tasks/database_tasks_test.rb index da7ca27f13..21226352ff 100644 --- a/activerecord/test/cases/tasks/database_tasks_test.rb +++ b/activerecord/test/cases/tasks/database_tasks_test.rb @@ -124,6 +124,14 @@ module ActiveRecord ActiveRecord::Base.connection_handler.stubs(:establish_connection) end + def test_ignores_configurations_without_databases + @configurations["development"].merge!("database" => nil) + + ActiveRecord::Tasks::DatabaseTasks.expects(:create).never + + ActiveRecord::Tasks::DatabaseTasks.create_all + end + def test_ignores_remote_databases @configurations["development"].merge!("host" => "my.server.tld") $stderr.stubs(:puts).returns(nil) @@ -242,6 +250,14 @@ module ActiveRecord ActiveRecord::Base.stubs(:configurations).returns(@configurations) end + def test_ignores_configurations_without_databases + @configurations[:development].merge!("database" => nil) + + ActiveRecord::Tasks::DatabaseTasks.expects(:drop).never + + ActiveRecord::Tasks::DatabaseTasks.drop_all + end + def test_ignores_remote_databases @configurations[:development].merge!("host" => "my.server.tld") $stderr.stubs(:puts).returns(nil) diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index 8af364f1e4..b42ffe50d8 100644 --- a/railties/lib/rails/application/configuration.rb +++ b/railties/lib/rails/application/configuration.rb @@ -179,7 +179,6 @@ module Rails values.reverse_merge!(shared) end end - loaded_yaml.delete("default") Hash.new(shared).merge(loaded_yaml) elsif ENV["DATABASE_URL"] # Value from ENV['DATABASE_URL'] is set to default database connection