Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Resolve undefined method migration_context when upgrading to rails 7.2 #162

Merged
merged 7 commits into from
Aug 16, 2024

Conversation

avinhurry
Copy link
Collaborator

@avinhurry avinhurry commented Aug 15, 2024

Context

We are getting the following error when upgrading our apps to rails version 7.2:

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:

Dropping Ruby 2.7 tests in CI as that version has reached it's EOL.

image

This PR also sets functional versions of the rspec-rails and rails gems depending on what version of rails you are using.

@avinhurry avinhurry force-pushed the fix-undefined-method-migration-context-2 branch 8 times, most recently from 4062cb9 to 281095a Compare August 15, 2024 20:24
@avinhurry avinhurry added the Do not merge Not ready for merging label Aug 15, 2024
@avinhurry avinhurry changed the title Add CI tests for rails 7.2 [DO NOT REVIEW] Add CI tests for rails 7.2 Aug 15, 2024
@avinhurry avinhurry force-pushed the fix-undefined-method-migration-context-2 branch 2 times, most recently from 133600c to a9fc34d Compare August 15, 2024 21:05
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/
@avinhurry avinhurry force-pushed the fix-undefined-method-migration-context-2 branch from a9fc34d to edbbd58 Compare August 15, 2024 21:09
@avinhurry avinhurry changed the title [DO NOT REVIEW] Add CI tests for rails 7.2 [DO NOT REVIEW] Resolve undefined method migration_context when upgrading to rails 7.2 Aug 15, 2024
@avinhurry avinhurry force-pushed the fix-undefined-method-migration-context-2 branch 3 times, most recently from 7b63d87 to 406ae49 Compare August 15, 2024 21:38
Ruby 2.7 reached its EOL on 2023-03-31
@avinhurry avinhurry force-pushed the fix-undefined-method-migration-context-2 branch from 406ae49 to 32dc3b9 Compare August 15, 2024 21:40
To maintain test coverage
@avinhurry avinhurry changed the title [DO NOT REVIEW] Resolve undefined method migration_context when upgrading to rails 7.2 Resolve undefined method migration_context when upgrading to rails 7.2 Aug 15, 2024
@avinhurry avinhurry marked this pull request as ready for review August 15, 2024 22:43
@avinhurry avinhurry requested a review from ericaporter August 15, 2024 22:43
@defong
Copy link

defong commented Aug 16, 2024

Copy link
Collaborator

@asatwal asatwal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM

Copy link
Contributor

@ericaporter ericaporter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 thanks for picking this up @avinhurry

@ericaporter ericaporter merged commit ad15381 into main Aug 16, 2024
5 checks passed
@ericaporter ericaporter deleted the fix-undefined-method-migration-context-2 branch August 16, 2024 10:06
@ericaporter ericaporter mentioned this pull request Aug 16, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants