Skip to content

Commit

Permalink
Resolve undefined method `migration_context'
Browse files Browse the repository at this point in the history
When upgrading our apps to rails version 7.2:

Publish: DFE-Digital/publish-teacher-training#4445

Apply: DFE-Digital/apply-for-teacher-training#9692

Register: DFE-Digital/register-trainee-teachers#4562

We are getting the following error:

NoMethodError: undefined method `migration_context' for #<ActiveRecord::ConnectionAdapters::PostgreSQLAdapter:0x0000000000c620

raise ActiveRecord::PendingMigrationError if ActiveRecord::Base.connection.migration_context.needs_migration?

This is because of breaking changes and deprecation in rails 7.2:

ActiveRecord::Base.connection was changed to with_connection:

- https://blog.saeloun.com/2024/07/01/rails-adds-activerecord-base-with-connection/

This deprecation meant that rspec had to be upgraded:
- rspec/rspec-rails#2661

Set functional versions of the rspec-rails and rails gems depending on what version of rails you are using.
  • Loading branch information
avinhurry committed Aug 15, 2024
1 parent d92d0b9 commit 56773c6
Show file tree
Hide file tree
Showing 14 changed files with 1,202 additions and 609 deletions.
8 changes: 8 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
appraise "rails-6" do
gem "rspec-rails", "5.1.2"
gem "rails", "6.0.6"
gem 'psych', '< 4'
end

appraise "rails-6.1" do
gem "rspec-rails", "6.1.3"
gem "rails", "6.1.7"
end

appraise "rails-7" do
gem "rspec-rails", "6.1.3"
gem "rails", "7.0.4"
end

appraise "rails-7.2" do
gem "rspec-rails", "6.1.3"
gem "rails", "7.2"
end
Loading

0 comments on commit 56773c6

Please sign in to comment.