@@ -10,20 +10,20 @@ module DatabaseTasks
1010 extend self
1111
1212 # These method are only introduced in Rails 7.1
13- unless respond_to? ( :with_temporary_connection_for_each )
14- def with_temporary_connection_for_each ( env : ActiveRecord ::Tasks ::DatabaseTasks . env , name : nil , &block ) # :nodoc:
13+ unless respond_to? ( :with_temporary_pool_for_each )
14+ def with_temporary_pool_for_each ( env : ActiveRecord ::Tasks ::DatabaseTasks . env , name : nil , &block ) # :nodoc:
1515 if name
1616 db_config = ActiveRecord ::Base . configurations . configs_for ( env_name : env , name : name )
17- with_temporary_connection ( db_config , &block )
17+ with_temporary_pool ( db_config , &block )
1818 else
1919 ActiveRecord ::Base . configurations . configs_for ( env_name : env , name : name ) . each do |db_config |
20- with_temporary_connection ( db_config , &block )
20+ with_temporary_pool ( db_config , &block )
2121 end
2222 end
2323 end
2424
25- def with_temporary_connection ( db_config , clobber : false , &block ) # :nodoc:
26- with_temporary_pool ( db_config , clobber : clobber ) do |pool |
25+ def with_temporary_connection ( db_config , &block ) # :nodoc:
26+ with_temporary_pool ( db_config ) do |pool |
2727 pool . with_connection ( &block )
2828 end
2929 end
@@ -36,21 +36,21 @@ def migration_connection # :nodoc:
3636 migration_class . connection
3737 end
3838
39- private def with_temporary_pool ( db_config , clobber : false )
39+ private def with_temporary_pool ( db_config )
4040 original_db_config = migration_class . connection_db_config
41- pool = migration_class . connection_handler . establish_connection ( db_config , clobber : clobber )
41+ pool = migration_class . connection_handler . establish_connection ( db_config )
4242
4343 yield pool
4444 ensure
45- migration_class . connection_handler . establish_connection ( original_db_config , clobber : clobber )
45+ migration_class . connection_handler . establish_connection ( original_db_config )
4646 end
4747 end
4848
4949 def db_configs_with_versions
5050 db_configs_with_versions = Hash . new { |h , k | h [ k ] = [ ] }
5151
52- with_temporary_connection_for_each do |conn |
53- db_config = conn . pool . db_config
52+ with_temporary_pool_for_each do |pool |
53+ db_config = pool . db_config
5454 if db_config . primary?
5555 versions_to_run = DataMigrate ::DatabaseTasks . pending_data_migrations . map { |m | m [ :version ] }
5656 target_version = ActiveRecord ::Tasks ::DatabaseTasks . target_version
0 commit comments