Skip to content

Commit b1d94e5

Browse files
pass internal_metadata to ActiveRecord::Migrator for 7.1 or above
1 parent 48b7493 commit b1d94e5

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

test/test_helper.rb

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,14 @@ def setup
3434
@connection.tables.each { |table| @connection.drop_table table, force: :cascade }
3535
# only instanciate ActiveRecord::SchemaMigration with the right connection for Activerecord 7.1 or above
3636
if Gem::Requirement.new('>=7.1.0').satisfied_by?(Gem::Version.new(::ActiveRecord::VERSION::STRING))
37-
ActiveRecord::SchemaMigration.new(@connection).create_table
38-
ActiveRecord::InternalMetadata.new(@connection).create_table
37+
@schema_migration = ActiveRecord::SchemaMigration.new(@connection)
38+
@internal_metadata = ActiveRecord::InternalMetadata.new(@connection)
3939
else
40-
ActiveRecord::SchemaMigration.create_table
41-
ActiveRecord::InternalMetadata.create_table
40+
@schema_migration = ActiveRecord::SchemaMigration
41+
@internal_metadata = ActiveRecord::InternalMetadata
4242
end
43+
@schema_migration.create_table
44+
@internal_metadata.create_table
4345
ActiveRecord::Migration.verbose = false
4446
@connection.execute("SET statement_timeout TO '70s'")
4547
@connection.execute("SET lock_timeout TO '70s'")
@@ -59,8 +61,10 @@ def run_migration(direction = :up)
5961
@migration.version = DUMMY_MIGRATION_VERSION
6062

6163
migrator =
62-
if Gem::Requirement.new('>=6.0.0').satisfied_by?(Gem::Version.new(::ActiveRecord::VERSION::STRING))
63-
ActiveRecord::Migrator.new(direction, [@migration], ActiveRecord::SchemaMigration)
64+
if Gem::Requirement.new('>=7.1.0').satisfied_by?(Gem::Version.new(::ActiveRecord::VERSION::STRING))
65+
ActiveRecord::Migrator.new(direction, [@migration], @schema_migration, @internal_metadata)
66+
elsif Gem::Requirement.new('>=6.0.0').satisfied_by?(Gem::Version.new(::ActiveRecord::VERSION::STRING))
67+
ActiveRecord::Migrator.new(direction, [@migration], @schema_migration)
6468
else
6569
ActiveRecord::Migrator.new(direction, [@migration])
6670
end

0 commit comments

Comments
 (0)