Method: ActiveRecord::Tasks::DatabaseTasks#db_configs_with_versions

Defined in:
activerecord/lib/active_record/tasks/database_tasks.rb

#db_configs_with_versions(environment = env) ⇒ Object

:nodoc:



277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
# File 'activerecord/lib/active_record/tasks/database_tasks.rb', line 277

def db_configs_with_versions(environment = env) # :nodoc:
  db_configs_with_versions = Hash.new { |h, k| h[k] = [] }

  with_temporary_pool_for_each(env: environment) do |pool|
    db_config = pool.db_config
    versions_to_run = pool.migration_context.pending_migration_versions
    target_version = ActiveRecord::Tasks::DatabaseTasks.target_version

    versions_to_run.each do |version|
      next if target_version && target_version != version
      db_configs_with_versions[version] << db_config
    end
  end

  db_configs_with_versions
end