diff options
author | eileencodes <eileencodes@gmail.com> | 2018-04-06 10:23:04 -0400 |
---|---|---|
committer | eileencodes <eileencodes@gmail.com> | 2018-04-09 13:08:12 -0400 |
commit | 5ddcda6d5f560d27bbae877d6ba8fb687d1b1a3b (patch) | |
tree | 6e844c93f5909ef6ca460237e763cd4f2f1c3406 /activerecord | |
parent | fa5a028ed9fccf54bb320e6a99a5a539de4c57ba (diff) | |
download | rails-5ddcda6d5f560d27bbae877d6ba8fb687d1b1a3b.tar.gz rails-5ddcda6d5f560d27bbae877d6ba8fb687d1b1a3b.tar.bz2 rails-5ddcda6d5f560d27bbae877d6ba8fb687d1b1a3b.zip |
Don't create namespaced tasks if single db application
This was causing single db applications to have rake tasks named
`db:create:primary`. These tasks are only useful to multiple database
applications so they shouldn't be generated.
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/tasks/database_tasks.rb | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/tasks/database_tasks.rb b/activerecord/lib/active_record/tasks/database_tasks.rb index 0b26c720f7..521375954b 100644 --- a/activerecord/lib/active_record/tasks/database_tasks.rb +++ b/activerecord/lib/active_record/tasks/database_tasks.rb @@ -136,8 +136,13 @@ module ActiveRecord def for_each databases = Rails.application.config.load_database_yaml - ActiveRecord::DatabaseConfigurations.configs_for(Rails.env, databases) do |spec_name, _| - yield spec_name + database_configs = ActiveRecord::DatabaseConfigurations.configs_for(Rails.env, databases) + + # if this is a single database application we don't want tasks for each primary database + return if database_configs.count == 1 + + database_configs.each do |db_config| + yield db_config.spec_name end end |