MigrationParser: recognize tables passed via keyword arguments, ignore comments#1
Merged
Merged
Conversation
Migrations that touch tables only through helper methods (e.g.
partition-conversion DSLs calling with table: :events) rendered an empty
tables column, since the parser only knew a closed list of ActiveRecord
DDL methods. A generic keyword pattern (table:, to_table:, from_table:)
now catches the whole helper family. Bare from:/to: are deliberately
excluded: change_column_default would yield phantom tables.
Ruby comments are stripped before scanning, so explanatory comments
mentioning ALTER TABLE or commented-out DSL calls no longer produce
phantom tables; #{} interpolation is preserved.
Also: dual-table methods now contribute their first argument even when
the second is passed as to_table:, and change_column_default /
change_column_null joined the single-table method list.
amberpixels
force-pushed
the
fix-migration-parser-helper-tables
branch
from
July 23, 2026 09:38
b69e76f to
7199b3b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Migrations that touch their tables only through project-level helper methods render an empty tables column in
db:migrate:status. Example: a partition-conversion migration whose entire body ishas no
create_table, no SQL literal, and no model constant, soMigrationParserreturned[]. Any codebase with migration helpers (strong_migrations-style shims, bulk-change DSLs, gem helpers) hits the same blind spot.Separately, the SQL patterns scan raw text, so a Ruby comment mentioning
ALTER TABLE fooproduced a phantom table.Changes
table:,to_table:, andfrom_table:keywords now yield their table name regardless of the method they're passed to - one pattern covers the whole helper family with no per-project configuration. Barefrom:/to:are deliberately excluded:change_column_default :apples, :status, from: nil, to: "ripe"would extract "nil"/"ripe" as tables.#comments are removed before any pattern scan (#{}interpolation is preserved), so commented-out DDL and explanatory SQL mentions no longer count.add_foreign_key/remove_foreign_key) now contribute their first argument even when the second is passed asto_table:;change_column_defaultandchange_column_nulljoined the single-table methods.Tests
9 new examples covering keyword extraction (symbol/string values,
to_table:, thefrom:/to:guard, a realistic partition-conversion migration body) and comment stripping (comment-only SQL mentions, commented-out DSL, interpolation preservation). Full suite: 298 examples, 0 failures; standardrb clean.