Skip to content

Commit

Permalink
Don't create namespaced tasks if single db application
Browse files Browse the repository at this point in the history
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 9, 2018
1 parent fa5a028 commit 5ddcda6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions activerecord/lib/active_record/tasks/database_tasks.rb
Expand Up @@ -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

Expand Down

0 comments on commit 5ddcda6

Please sign in to comment.