Skip to content

Commit

Permalink
Use connection_pool over chaining calls
Browse files Browse the repository at this point in the history
  • Loading branch information
vprigent committed Jun 9, 2024
1 parent 22c2776 commit 87b9660
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions lib/data_migrate/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/data_migrate/migration_context_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 87b9660

Please sign in to comment.