From ae01c921fb12021e46407f6d17ff68528156017d Mon Sep 17 00:00:00 2001 From: eileencodes Date: Thu, 22 Feb 2018 15:40:13 -0500 Subject: Revert "Merge pull request #32075 from eileencodes/delete-default-configuration" This reverts commit 16f279ebd474626577ced858e3626ac4535a33df, reversing changes made to 6c6a30a7c357ce1eafa093d77d2b08684fe50887. The config can be named anything, not just default (although all generated apps will be named default). We can't just delete configs that don't have a database because that will break three-tier configs. Oh well. --- activerecord/lib/active_record/tasks/database_tasks.rb | 4 ++++ activerecord/test/cases/tasks/database_tasks_test.rb | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) (limited to 'activerecord') 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) -- cgit v1.2.3