Skip to content

Commit

Permalink
Fix CI for rails HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
fatkodima committed Feb 22, 2024
1 parent c47ab69 commit 384c115
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
6 changes: 5 additions & 1 deletion test/alphabetize_schema_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ def test_enabled
private
def dump_schema
io = StringIO.new
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, io)
if OnlineMigrations::Utils.ar_version >= 7.2
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection.pool, io)
else
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, io)
end
io.string
end
end
12 changes: 9 additions & 3 deletions test/support/minitest_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ def assert_nothing_raised
def migrate(migration, direction: :up, version: 1)
connection = ActiveRecord::Base.connection

if OnlineMigrations::Utils.ar_version >= 7.1
if OnlineMigrations::Utils.ar_version >= 7.2
ActiveRecord::SchemaMigration.new(connection.pool).delete_all_versions
elsif OnlineMigrations::Utils.ar_version >= 7.1
ActiveRecord::SchemaMigration.new(connection).delete_all_versions
else
ActiveRecord::SchemaMigration.delete_all
Expand All @@ -25,15 +27,19 @@ def migrate(migration, direction: :up, version: 1)
migration.version ||= version

if direction == :down
if OnlineMigrations::Utils.ar_version >= 7.1
if OnlineMigrations::Utils.ar_version >= 7.2
ActiveRecord::SchemaMigration.new(connection.pool).create_version(migration.version)
elsif OnlineMigrations::Utils.ar_version >= 7.1
ActiveRecord::SchemaMigration.new(connection).create_version(migration.version)
else
ActiveRecord::SchemaMigration.create!(version: migration.version)
end
end

args =
if OnlineMigrations::Utils.ar_version >= 7.1
if OnlineMigrations::Utils.ar_version >= 7.2
[ActiveRecord::SchemaMigration.new(connection.pool), ActiveRecord::InternalMetadata.new(connection.pool)]
elsif OnlineMigrations::Utils.ar_version >= 7.1
[ActiveRecord::SchemaMigration.new(connection), ActiveRecord::InternalMetadata.new(connection)]
else
[ActiveRecord::SchemaMigration]
Expand Down
4 changes: 3 additions & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ def prepare_database
connection.drop_table(table_name, force: :cascade)
end

if OnlineMigrations::Utils.ar_version >= 7.1
if OnlineMigrations::Utils.ar_version >= 7.2
ActiveRecord::SchemaMigration.new(connection.pool).create_table
elsif OnlineMigrations::Utils.ar_version >= 7.1
ActiveRecord::SchemaMigration.new(connection).create_table
else
ActiveRecord::SchemaMigration.create_table
Expand Down

0 comments on commit 384c115

Please sign in to comment.