Skip to content

Fix --show-migration option not working on Rails 7.2+.#327

Open
OdenTakashi wants to merge 1 commit intomainfrom
fix/show-migration-rails-7.2
Open

Fix --show-migration option not working on Rails 7.2+.#327
OdenTakashi wants to merge 1 commit intomainfrom
fix/show-migration-rails-7.2

Conversation

@OdenTakashi
Copy link
Copy Markdown
Collaborator

@OdenTakashi OdenTakashi commented Apr 21, 2026

Problem

ConnectionAdapter#migration_context was deprecated in Rails 7.1 and removed in Rails 7.2 (rails/rails#51162).
The existing code called connection.migration_context.current_version, which raises NoMethodError on Rails 7.2+.

Solution

Use connection.pool.migration_context when available (Rails 7.1+), falling back to connection.migration_context for older versions.

Copy link
Copy Markdown
Contributor

@olleolleolle olleolleolle left a comment

Choose a reason for hiding this comment

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

Very clear fix!

Also, good to have the version reference in place, so that we can drop unused code paths in the future.

## Problem
`ConnectionAdapter#migration_context` was deprecated in Rails 7.1 and removed in Rails 7.2 (rails/rails#51162).
`The existing code called
`connection.migration_context.current_version`, which raises `NoMethodError` on Rails 7.2+.

## Solution
Use `connection.pool.migration_context` when available (Rails 7.1+), falling back to `connection.migration_context` for older versions.
@OdenTakashi OdenTakashi force-pushed the fix/show-migration-rails-7.2 branch from fe45ac7 to 8a86229 Compare May 5, 2026 13:31
@OdenTakashi
Copy link
Copy Markdown
Collaborator Author

Thank you for the review and the kind words!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants