From 06f7c6c4c560f04c190d5a0b8af37bd46f706309 Mon Sep 17 00:00:00 2001 From: Brian Estrada Date: Wed, 14 Oct 2026 07:34:43 +0000 Subject: [PATCH] fix(check-migration-order): ignore repeatable migrations when finding the newest version [NOJIRA] --- .github/actions/check-migration-order/README.md | 4 ++++ .../actions/check-migration-order/check-migration-order.sh | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/actions/check-migration-order/README.md b/.github/actions/check-migration-order/README.md index 9b06e16..49ddc98 100644 --- a/.github/actions/check-migration-order/README.md +++ b/.github/actions/check-migration-order/README.md @@ -114,6 +114,10 @@ are therefore left alone rather than reported. - Scope is Flyway-style versioned filenames. Version *extraction* (strip a leading `B`/`V`, strip `__description`) is Flyway-specific; Laravel- or Prisma-style migrations would need a second extraction mode. +- Only `B`/`V` files set the base branch's newest version. Repeatable (`R__`) + migrations and callbacks have no version; counted naively, service-grid's + `R__monta_service_provider_seed.sql` became version `R`, which `sort -V` + places after every timestamp, so no new migration could pass. ## Limitation worth knowing diff --git a/.github/actions/check-migration-order/check-migration-order.sh b/.github/actions/check-migration-order/check-migration-order.sh index a257825..772b323 100755 --- a/.github/actions/check-migration-order/check-migration-order.sh +++ b/.github/actions/check-migration-order/check-migration-order.sh @@ -28,6 +28,11 @@ merge_base=$(git merge-base HEAD "$base") # Strip directory, the B/V prefix and the __description suffix. versions() { sed -E 's|.*/||; s|^[BV]||; s|__.*$||'; } +# Only versioned (V) and baseline (B) migrations have a version. Repeatable +# (R__) and callback files have none, and would otherwise parse as e.g. "R", +# which sort -V places after every timestamp. +versioned() { grep -E '(^|/)[BV][0-9][^/]*\.sql$' || true; } + # A root is a directory named "migration" under src/main/resources holding at # least one .sql somewhere beneath it -- NOT every directory that contains a # .sql. Flyway pools all of a root's subdirectories (common/, /, @@ -93,7 +98,7 @@ check_root() { local base_max base_max=$( git ls-tree -r --name-only "$base" -- "$migrations" | - { grep -E '\.sql$' || true; } | versions | sort -V | tail -1 + versioned | versions | sort -V | tail -1 ) echo " newest migration on $base: ${base_max:-}"