Skip to content

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

Merged
drwl merged 1 commit into
mainfrom
fix/show-migration-rails-7.2
May 8, 2026
Merged

Fix --show-migration option not working on Rails 7.2+.#327
drwl merged 1 commit into
mainfrom
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!

Copy link
Copy Markdown
Owner

@drwl drwl left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this. It's always a bit tricky as the Rails API changes across versions.

@drwl drwl merged commit 74c29eb into main May 8, 2026
26 checks passed
@drwl drwl deleted the fix/show-migration-rails-7.2 branch May 8, 2026 22:50
@OdenTakashi
Copy link
Copy Markdown
Collaborator Author

Thanks for revewing this.

Since this kind of issue can break differently depending on the Rails version, I think it would be good to include Rails versions in the CI matrix as well.

That should help us catch compatibility issues like this earlier, especially around deprecated or removed Rails APIs.

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.

3 participants