Skip to content

Commit

Permalink
added code to 61 gemfile to fix issues with concurrent_ruby version a…
Browse files Browse the repository at this point in the history
…nd added logic to MigrationHelper to deal with versions above and below Rails 7.0
  • Loading branch information
Andy Reilly committed Jan 22, 2025
1 parent d5961e7 commit 9a967ec
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
1 change: 1 addition & 0 deletions gemfiles/rails_61.gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
source 'https://rubygems.org'

gem 'rails', '~> 6.1.0'
gem 'concurrent-ruby', '1.3.4'
gem 'rails-controller-testing'
gem 'sqlite3', '~> 1.4'
gem 'rspec-rails', '>= 5.0'
Expand Down
23 changes: 14 additions & 9 deletions spec/support/migration_helper.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
class MigrationHelper
class << self
def migrate(path)
ActiveRecord::MigrationContext.new(path).migrate
if Rails.version >= '7.0'
ActiveRecord::MigrationContext.new(path).migrate
elsif Rails.version < '7.0'
ActiveRecord::MigrationContext.new(path, schema_migration).migrate
end
end

def rollback(path)
ActiveRecord::MigrationContext.new(path).rollback
if Rails.version >= '7.0'
ActiveRecord::MigrationContext.new(path).rollback
elsif Rails.version < '7.0'
ActiveRecord::MigrationContext.new(path, schema_migration).rollback
end
end

# private
# Commenting out as this is not needed. Was causing error due to deprecation of .connection superseded by
# .with_connection. Removed schema_migration from new(path, schema_migrations) since it is optional
# and all test now passing with rails 7.2.
# def schema_migration
# ActiveRecord::Base.connection.schema_migration
# end
private
def schema_migration
ActiveRecord::Base.connection.schema_migration
end
end
end

0 comments on commit 9a967ec

Please sign in to comment.