MemberJunction / MemberJunction/MJ

CI: changes.yml "Check migration filenames" rejects all baselines (B-prefixed migrations)

Open Beginner friendly
#3,125 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
TSQL
Stars
29
Forks
6
Avg merge
2d 1h
Merged PRs (30d)
323

Description

## Summary

The `Check migration filenames` step in `.github/workflows/changes.yml` cannot pass any release that ships a **baseline** migration. It flagged the v5.47 release PR (#3124) on `B202607091514__v5.46.x__Baseline.sql`.

## Why it fails

The step globs **all** newly-added `migrations/*.sql` files and requires each to (a) contain `__v` and (b) contain a capital `V`:

```bash
git diff --name-only --diff-filter=A "$BASE" "$HEAD" | grep -E '^migrations/.*\.sql$' | while read file; do
if [[ ! "$file" =~ $EXPECTED_STRING ]]; then ... exit 1; fi # version tag
if [[ ! "$file" =~ "V" ]]; then ... exit 1; fi # capital V
done
```

Baselines are named `B__v.x__Baseline.sql` and fail on **both** counts:
1. **Version tag** — a baseline carries the version of the schema it snapshots, which need not equal the release's next-minor. The v5.47 release ships `B202607091514__v5.46.x__Baseline.sql` (created *after* v5.46.0 was tagged, so it missed that release and rolled forward) → tag is `__v5.46`, gate expects `__v5.47`.
2. **Capital `V`** — baselines start with `B` by definition. `[[ "$file" =~ "V" ]]` matches a capital V anywhere in the path; a baseline path (`migrations/v5/B..._Baseline.sql`) has none. **No baseline can ever satisfy this check.**

## Why it wasn't caught before

The check only began *actually executing* on 2026-06-11 (`d037893d6d` — "fetch PR base commit so validation actually runs"). Before that, `git diff base.sha head` couldn't resolve the base SHA on the shallow clone, returned empty, and the `while` loop never ran — the step passed vacuously. Every prior baseline (v5.34 / v5.37 / v5.38, all pre-June-11) shipped without ever being validated. v5.47 is the first baseline to face the gate for real.

## Proposed fix

Exempt `B`-prefixed baselines from the filename naming rules (they are full snapshots, not incremental V-migrations):

```bash
git diff --name-only --diff-filter=A "$BASE" "$HEAD" | grep -E '^migrations/.*\.sql$' | while read file; do
base=$(basename "$file")
if [[ "$base" =~ ^B[0-9]{12}__ ]]; then
echo "Skipping baseline: $base"
continue
fi
# existing version + capital-V checks unchanged
done
```

Optional hardening (separate): the capital-`V` check should assert the **basename starts with** `V`, not that a `V` appears anywhere in the path.

## Impact / workaround

- Blocks any release PR that adds a baseline.
- Interim: merge affected release PRs after confirming all other checks are green (the failure is a false positive on a correctly-formed baseline).

Found during the **v5.47.0** release (PR #3124).

Contributor guide

Open the contributing guide

Research direction

Start in .github/workflows/changes.yml at the “Check migration filenames” step and review how newly added migrations are selected and validated. Confirm the behavior for B-prefixed baseline files and existing V migrations, then run the workflow checks against a change containing a baseline and incremental migration; done means valid baselines no longer fail while the existing naming rules still apply.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash, github-actions, sql
Domain
ci-cd, databases
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.