Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/actions/check-migration-order/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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/, <env>/,
Expand Down Expand Up @@ -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:-<none>}"

Expand Down