Skip to content

Commit 0182d27

Browse files
committed
Added Active Record 7.1 to CI
1 parent 1cbe891 commit 0182d27

4 files changed

Lines changed: 39 additions & 5 deletions

File tree

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ jobs:
77
fail-fast: false
88
matrix:
99
include:
10+
- ruby: 3.2.0-preview2
11+
gemfile: gemfiles/activerecord71.gemfile
1012
- ruby: 3.1
1113
gemfile: Gemfile
1214
- ruby: "3.0"

gemfiles/activerecord71.gemfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
source "https://rubygems.org"
2+
3+
gemspec path: ".."
4+
5+
gem "rake"
6+
gem "minitest", ">= 5"
7+
gem "activerecord", github: "rails/rails"
8+
gem "pg"
9+
gem "mysql2"

lib/strong_migrations/safe_methods.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def safe_add_check_constraint(table, expression, *args, add_options, validate_op
6464
@migration.validate_check_constraint(table, **validate_options)
6565
end
6666
dir.down do
67-
@migration.remove_check_constraint(table, expression, **add_options)
67+
@migration.remove_check_constraint(table, expression, **add_options.except(:validate))
6868
end
6969
end
7070
end

test/test_helper.rb

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,15 @@ def migration_version
2727
TestMigration = ActiveRecord::Migration[migration_version]
2828
TestSchema = 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

3240
ActiveRecord::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

Comments
 (0)