diff options
author | Eileen Uchitelle <eileencodes@gmail.com> | 2018-08-31 10:55:37 -0400 |
---|---|---|
committer | Eileen Uchitelle <eileencodes@gmail.com> | 2018-08-31 16:07:09 -0400 |
commit | a572d2283b05c4c05c220ff520732fc570beb2ae (patch) | |
tree | 4791f610ea5bd65f6ca4581c593831dcc3f6db85 /activerecord/lib/active_record/tasks | |
parent | 8737dffce73a37dff073dfe0af8931efd08632c5 (diff) | |
download | rails-a572d2283b05c4c05c220ff520732fc570beb2ae.tar.gz rails-a572d2283b05c4c05c220ff520732fc570beb2ae.tar.bz2 rails-a572d2283b05c4c05c220ff520732fc570beb2ae.zip |
Convert configs_for to kwargs, add include_replicas
Changes the `configs_for` method from using traditional arguments to
using kwargs. This is so I can add the `include_replicas` kwarg without
having to always include `env_name` and `spec_name` in the method call.
`include_replicas` defaults to false because everywhere internally in
Rails we don't want replicas. `configs_for` is for iterating over
configurations to create / run rake tasks, so we really don't ever need
replicas in that case.
Diffstat (limited to 'activerecord/lib/active_record/tasks')
-rw-r--r-- | activerecord/lib/active_record/tasks/database_tasks.rb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/tasks/database_tasks.rb b/activerecord/lib/active_record/tasks/database_tasks.rb index 3a1791f9c7..16e66982e5 100644 --- a/activerecord/lib/active_record/tasks/database_tasks.rb +++ b/activerecord/lib/active_record/tasks/database_tasks.rb @@ -117,7 +117,7 @@ module ActiveRecord if options.has_key?(:config) @current_config = options[:config] else - @current_config ||= ActiveRecord::Base.configurations.configs_for(options[:env], options[:spec]).config + @current_config ||= ActiveRecord::Base.configurations.configs_for(env_name: options[:env], spec_name: options[:spec]).config end end @@ -143,7 +143,7 @@ module ActiveRecord def for_each databases = Rails.application.config.database_configuration - database_configs = ActiveRecord::DatabaseConfigurations.new(databases).configs_for(Rails.env) + database_configs = ActiveRecord::DatabaseConfigurations.new(databases).configs_for(env_name: Rails.env) # if this is a single database application we don't want tasks for each primary database return if database_configs.count == 1 @@ -208,7 +208,7 @@ module ActiveRecord end def charset_current(environment = env, specification_name = spec) - charset ActiveRecord::Base.configurations.configs_for(environment, specification_name).config + charset ActiveRecord::Base.configurations.configs_for(env_name: environment, spec_name: specification_name).config end def charset(*arguments) @@ -217,7 +217,7 @@ module ActiveRecord end def collation_current(environment = env, specification_name = spec) - collation ActiveRecord::Base.configurations.configs_for(environment, specification_name).config + collation ActiveRecord::Base.configurations.configs_for(env_name: environment, spec_name: specification_name).config end def collation(*arguments) @@ -351,7 +351,7 @@ module ActiveRecord environments << "test" if environment == "development" environments.each do |env| - ActiveRecord::Base.configurations.configs_for(env).each do |db_config| + ActiveRecord::Base.configurations.configs_for(env_name: env).each do |db_config| yield db_config.config, db_config.spec_name, env end end |