@@ -34,12 +34,14 @@ def setup
34
34
@connection . tables . each { |table | @connection . drop_table table , force : :cascade }
35
35
# only instanciate ActiveRecord::SchemaMigration with the right connection for Activerecord 7.1 or above
36
36
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 )
39
39
else
40
- ActiveRecord ::SchemaMigration . create_table
41
- ActiveRecord ::InternalMetadata . create_table
40
+ @schema_migration = ActiveRecord ::SchemaMigration
41
+ @internal_metadata = ActiveRecord ::InternalMetadata
42
42
end
43
+ @schema_migration . create_table
44
+ @internal_metadata . create_table
43
45
ActiveRecord ::Migration . verbose = false
44
46
@connection . execute ( "SET statement_timeout TO '70s'" )
45
47
@connection . execute ( "SET lock_timeout TO '70s'" )
@@ -59,8 +61,10 @@ def run_migration(direction = :up)
59
61
@migration . version = DUMMY_MIGRATION_VERSION
60
62
61
63
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 )
64
68
else
65
69
ActiveRecord ::Migrator . new ( direction , [ @migration ] )
66
70
end
0 commit comments