Permalink
Browse files

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.
  • Loading branch information...
eileencodes committed Apr 6, 2018
1 parent fa5a028 commit 5ddcda6d5f560d27bbae877d6ba8fb687d1b1a3b
Showing with 7 additions and 2 deletions.
  1. +7 −2 activerecord/lib/active_record/tasks/database_tasks.rb
@@ -136,8 +136,13 @@ def create_all
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

0 comments on commit 5ddcda6

Please sign in to comment.