@@ -27,7 +27,15 @@ def migration_version
2727TestMigration = ActiveRecord ::Migration [ migration_version ]
2828TestSchema = ActiveRecord ::Schema
2929
30- ActiveRecord ::SchemaMigration . create_table
30+ def schema_migration
31+ if ActiveRecord ::VERSION ::STRING . to_f >= 7.1
32+ ActiveRecord ::Base . connection . schema_migration
33+ else
34+ ActiveRecord ::SchemaMigration
35+ end
36+ end
37+
38+ schema_migration . create_table
3139
3240ActiveRecord ::Schema . define do
3341 enable_extension "citext" if $adapter == "postgresql"
@@ -79,13 +87,28 @@ class Minitest::Test
7987 include Helpers
8088
8189 def migrate ( migration , direction : :up )
82- ActiveRecord ::SchemaMigration . delete_all
90+ if ActiveRecord ::VERSION ::STRING . to_f >= 7.1
91+ schema_migration . delete_all_versions
92+ else
93+ schema_migration . delete_all
94+ end
8395 migration = migration . new unless migration . is_a? ( TestMigration )
8496 migration . version ||= 123
8597 if direction == :down
86- ActiveRecord ::SchemaMigration . create! ( version : migration . version )
98+ if ActiveRecord ::VERSION ::STRING . to_f >= 7.1
99+ schema_migration . create_version ( migration . version )
100+ else
101+ schema_migration . create! ( version : migration . version )
102+ end
87103 end
88- args = ActiveRecord ::VERSION ::MAJOR >= 6 ? [ ActiveRecord ::SchemaMigration ] : [ ]
104+ args =
105+ if ActiveRecord ::VERSION ::STRING . to_f >= 7.1
106+ [ schema_migration , ActiveRecord ::Base . connection . internal_metadata ]
107+ elsif ActiveRecord ::VERSION ::MAJOR >= 6
108+ [ schema_migration ]
109+ else
110+ [ ]
111+ end
89112 ActiveRecord ::Migrator . new ( direction , [ migration ] , *args ) . migrate
90113 true
91114 rescue => e
0 commit comments