Skip to content

Commit e4aefab

Browse files
committed
Use connection_pool over chaining calls
1 parent c4456b0 commit e4aefab

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

Changelog.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
## 9.5.0
5-
- Support Rails 7.2
5+
- Support Rails 7.2 https://github.com/ilyakatz/data-migrate/pull/312
66

77
## 9.4.2
88
- Fix db:prepare:with_data task

lib/data_migrate/rails_helper.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def rails_version_equal_to_or_higher_than_7_0
2020

2121
def internal_metadata
2222
if rails_version_equal_to_or_higher_than_7_2
23-
ActiveRecord::Base.connection.pool.internal_metadata
23+
ActiveRecord::Base.connection_pool.internal_metadata
2424
elsif rails_version_equal_to_or_higher_than_7_1
2525
ActiveRecord::Base.connection.internal_metadata
2626
else
@@ -30,7 +30,7 @@ def internal_metadata
3030

3131
def schema_migration
3232
if rails_version_equal_to_or_higher_than_7_2
33-
ActiveRecord::Base.connection.pool.schema_migration
33+
ActiveRecord::Base.connection_pool.schema_migration
3434
elsif rails_version_equal_to_or_higher_than_7_1
3535
ActiveRecord::Base.connection.schema_migration
3636
else
@@ -64,7 +64,7 @@ def data_schema_delete_version(version)
6464

6565
def data_schema_migration
6666
if rails_version_equal_to_or_higher_than_7_2
67-
DataMigrate::DataSchemaMigration.new(ActiveRecord::Tasks::DatabaseTasks.migration_connection.pool)
67+
DataMigrate::DataSchemaMigration.new(ActiveRecord::Tasks::DatabaseTasks.migration_connection_pool)
6868
elsif rails_version_equal_to_or_higher_than_7_1
6969
DataMigrate::DataSchemaMigration.new(ActiveRecord::Tasks::DatabaseTasks.migration_connection)
7070
else

spec/data_migrate/migration_context_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@
108108

109109
# schema migration changed in Rails 7.2, from the connection to the pool object.
110110
def ar_schema_migration
111-
if ActiveRecord::Base.connection.pool.respond_to?(:schema_migration)
112-
ActiveRecord::Base.connection.pool.schema_migration
111+
if ActiveRecord::Base.connection_pool.respond_to?(:schema_migration)
112+
ActiveRecord::Base.connection_pool.schema_migration
113113
else
114114
ActiveRecord::Base.connection.schema_migration
115115
end

0 commit comments

Comments
 (0)