From 959c4e9224526aca6189652a44414e623ba7a726 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Thu, 6 Jun 2024 10:53:19 -0400 Subject: [PATCH] Moved `migration_context` method to connection pool --- app/lib/admin/system_check/database_schema_check.rb | 2 +- lib/tasks/tests.rake | 2 +- spec/lib/admin/system_check/database_schema_check_spec.rb | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/lib/admin/system_check/database_schema_check.rb b/app/lib/admin/system_check/database_schema_check.rb index c2f01fd55b5..a3ef0613ea0 100644 --- a/app/lib/admin/system_check/database_schema_check.rb +++ b/app/lib/admin/system_check/database_schema_check.rb @@ -6,7 +6,7 @@ class Admin::SystemCheck::DatabaseSchemaCheck < Admin::SystemCheck::BaseCheck end def pass? - !ActiveRecord::Base.connection.migration_context.needs_migration? + !ActiveRecord::Base.connection_pool.migration_context.needs_migration? end def message diff --git a/lib/tasks/tests.rake b/lib/tasks/tests.rake index c8e4dc31cd7..e3b1a67f24b 100644 --- a/lib/tasks/tests.rake +++ b/lib/tasks/tests.rake @@ -11,7 +11,7 @@ namespace :tests do '3_3_0' => 2020_12_18_054746, }.each do |release, version| ActiveRecord::Tasks::DatabaseTasks - .migration_connection + .migration_connection_pool .migration_context .migrate(version) Rake::Task["tests:migrations:populate_v#{release}"] diff --git a/spec/lib/admin/system_check/database_schema_check_spec.rb b/spec/lib/admin/system_check/database_schema_check_spec.rb index db1dcb52fa4..19f68995f0c 100644 --- a/spec/lib/admin/system_check/database_schema_check_spec.rb +++ b/spec/lib/admin/system_check/database_schema_check_spec.rb @@ -13,7 +13,7 @@ describe Admin::SystemCheck::DatabaseSchemaCheck do context 'when database needs migration' do before do context = instance_double(ActiveRecord::MigrationContext, needs_migration?: true) - allow(ActiveRecord::Base.connection).to receive(:migration_context).and_return(context) + allow(ActiveRecord::Base.connection_pool).to receive(:migration_context).and_return(context) end it 'returns false' do @@ -24,7 +24,7 @@ describe Admin::SystemCheck::DatabaseSchemaCheck do context 'when database does not need migration' do before do context = instance_double(ActiveRecord::MigrationContext, needs_migration?: false) - allow(ActiveRecord::Base.connection).to receive(:migration_context).and_return(context) + allow(ActiveRecord::Base.connection_pool).to receive(:migration_context).and_return(context) end it 'returns true' do