From 87b9660eee1b5c970c5ffdc65d03ac08473ab790 Mon Sep 17 00:00:00 2001 From: Vincent Prigent Date: Sun, 9 Jun 2024 22:31:41 +0200 Subject: [PATCH] Use connection_pool over chaining calls --- Changelog.md | 2 +- lib/data_migrate/rails_helper.rb | 6 +++--- spec/data_migrate/migration_context_spec.rb | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Changelog.md b/Changelog.md index 5c547a1..a1aa180 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,7 +1,7 @@ # Changelog ## 9.5.0 -- Support Rails 7.2 +- Support Rails 7.2 https://github.com/ilyakatz/data-migrate/pull/312 ## 9.4.0 - Reset model schema cache before each data migration https://github.com/ilyakatz/data-migrate/pull/307 diff --git a/lib/data_migrate/rails_helper.rb b/lib/data_migrate/rails_helper.rb index 330f50a..d71ae44 100644 --- a/lib/data_migrate/rails_helper.rb +++ b/lib/data_migrate/rails_helper.rb @@ -20,7 +20,7 @@ def rails_version_equal_to_or_higher_than_7_0 def internal_metadata if rails_version_equal_to_or_higher_than_7_2 - ActiveRecord::Base.connection.pool.internal_metadata + ActiveRecord::Base.connection_pool.internal_metadata elsif rails_version_equal_to_or_higher_than_7_1 ActiveRecord::Base.connection.internal_metadata else @@ -30,7 +30,7 @@ def internal_metadata def schema_migration if rails_version_equal_to_or_higher_than_7_2 - ActiveRecord::Base.connection.pool.schema_migration + ActiveRecord::Base.connection_pool.schema_migration elsif rails_version_equal_to_or_higher_than_7_1 ActiveRecord::Base.connection.schema_migration else @@ -64,7 +64,7 @@ def data_schema_delete_version(version) def data_schema_migration if rails_version_equal_to_or_higher_than_7_2 - DataMigrate::DataSchemaMigration.new(ActiveRecord::Tasks::DatabaseTasks.migration_connection.pool) + DataMigrate::DataSchemaMigration.new(ActiveRecord::Tasks::DatabaseTasks.migration_connection_pool) elsif rails_version_equal_to_or_higher_than_7_1 DataMigrate::DataSchemaMigration.new(ActiveRecord::Tasks::DatabaseTasks.migration_connection) else diff --git a/spec/data_migrate/migration_context_spec.rb b/spec/data_migrate/migration_context_spec.rb index 6b6ce80..4d14750 100644 --- a/spec/data_migrate/migration_context_spec.rb +++ b/spec/data_migrate/migration_context_spec.rb @@ -108,8 +108,8 @@ # schema migration changed in Rails 7.2, from the connection to the pool object. def ar_schema_migration - if ActiveRecord::Base.connection.pool.respond_to?(:schema_migration) - ActiveRecord::Base.connection.pool.schema_migration + if ActiveRecord::Base.connection_pool.respond_to?(:schema_migration) + ActiveRecord::Base.connection_pool.schema_migration else ActiveRecord::Base.connection.schema_migration end