Skip to content

fix(check-migration-order): ignore repeatable migrations when finding the newest version [NOJIRA] - #385

Merged
BrianEstrada merged 1 commit into
mainfrom
fix/check-migration-order-ignore-repeatable
Oct 14, 2026
Merged

BrianEstrada merged 1 commit into
mainfrom
fix/check-migration-order-ignore-repeatable

Conversation

@BrianEstrada

Copy link
Copy Markdown
Contributor

Summary

check-migration-order fails every new migration in a repo whose base branch has a repeatable (R__) migration.

base_max runs every .sql file name through versions(), which only strips a B/V prefix. So
R__monta_service_provider_seed.sql turns into the version R, and sort -V puts that after every numeric
timestamp. Every new V... migration then fails with "does not sort after R".

The fix only counts B/V files followed by a digit when it computes base_max. Repeatable migrations and
callbacks have no version, so they're left out. The README notes this under "Notes".

Found on

monta-app/service-grid#1184. It adds V2026.10.13.10.00__grid_asset_asset_type.sql, and main's newest versioned
migration is V2026.08.13.10.00
(failing job). The
R__ file has been on service-grid's main since 2022, so every service-grid PR that adds a migration fails until this lands.

Test plan

  • Ran the unpatched script against service-grid#1184's branch with the action's default naming pattern:
    newest migration on origin/main: R, then the error, exit 1.
  • Ran the patched script against the same branch: newest migration on origin/main: 2026.08.13.10.00,
    OK: V2026.10.13.10.00__grid_asset_asset_type.sql sorts after 2026.08.13.10.00, exit 0.
  • Ran the patched script against a scratch branch off service-grid main that adds V2026.08.01.10.00__stale.sql.
    It still fails with "does not sort after 2026.08.13.10.00".
  • bash -n passes. The naming check and the edited-migration check are unchanged.

@BrianEstrada
BrianEstrada requested a review from a team as a code owner October 14, 2026 07:34
@BrianEstrada
BrianEstrada requested review from tobias0106 and removed request for a team October 14, 2026 07:34
@BrianEstrada
BrianEstrada merged commit 84fb68d into main Oct 14, 2026
1 check passed
@BrianEstrada
BrianEstrada deleted the fix/check-migration-order-ignore-repeatable branch October 14, 2026 07:39
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.

1 participant