From 2dd230aab3f7b608acec99955e5d5d46a0c90d68 Mon Sep 17 00:00:00 2001 From: Theodor Tonum Date: Sun, 2 Jun 2024 12:25:32 +0200 Subject: [PATCH] Use ConnectionPool#schema_migration in Rails 7.2 See https://github.com/rails/rails/pull/51162 for details. --- spec/support/paper_trail_spec_migrator.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/spec/support/paper_trail_spec_migrator.rb b/spec/support/paper_trail_spec_migrator.rb index f53903cb..7a368e22 100644 --- a/spec/support/paper_trail_spec_migrator.rb +++ b/spec/support/paper_trail_spec_migrator.rb @@ -21,7 +21,7 @@ def initialize def migrate ::ActiveRecord::MigrationContext.new( @migrations_path, - ::ActiveRecord::Base.connection.schema_migration + schema_migration ).migrate end @@ -45,6 +45,14 @@ def generate_and_migrate(generator, generator_invoke_args) private + def schema_migration + if Rails::VERSION::STRING >= '7.2' + ::ActiveRecord::Base.connection_pool.schema_migration + else + ::ActiveRecord::Base.connection.schema_migration + end + end + def dummy_app_migrations_dir Pathname.new(File.expand_path("../dummy_app/db/migrate", __dir__)) end