Files
mattermost/.github/workflows
7fbbf0beef Add CI check to prevent renumbering or renaming existing DB migrations (#37099)
* Add CI check to prevent renumbering or renaming existing DB migrations

Backporting or rebasing a PR can accidentally change the sequence number
or description of a migration that already shipped on master, which
corrupts the upgrade path for existing installations (see MM-68848).

This adds a migration_check tool that compares the working tree's
migration files against the base branch and fails when an existing
migration's version or name differs. Brand new migrations are ignored.
It is wired into the existing "Check migration files" CI job via a new
`make check-migration-changes` target.

Co-authored-by: mattermost-code <matty-code@mattermost.com>

* Apply go fix strings.SplitSeq in migration_check

Co-authored-by: mattermost-code <matty-code@mattermost.com>

* Retrigger CI after transient Enterprise npm failure

Co-authored-by: mattermost-code <matty-code@mattermost.com>

* Use github.ref_name as migration check base ref fallback on push

Co-authored-by: mattermost-code <matty-code@mattermost.com>

* Flag shipped migrations missing from branch by version and name

Add reverse comparison so deletions and simultaneous renumber+rename are
caught, per CodeRabbit review feedback.

Co-authored-by: mattermost-code <matty-code@mattermost.com>

* Address PR feedback: 0 answered, 2 resolved, 0 declined

* Address PR feedback: 2 answered, 1 resolved, 1 declined

* Fix migration check direction and scope to release branches

Address isacikgoz review feedback:
- Reverse the comparison so it flags migration files the branch HAS that
  the base branch (origin/master) does NOT, instead of flagging base
  migrations missing from the branch. A backport branch is an older subset
  of master, so the old direction reported every newer master migration as
  an error.
- Include the up/down kind in the comparison key so a one-sided rename of
  only the .up or .down file is no longer masked by its surviving partner.
- Restrict the CI step to PRs targeting release-* branches, where the head
  is expected to be a subset of master; on master-targeted PRs new
  migrations are normal and would otherwise be flagged as stray.

* Scope migration check to PR-added Postgres migrations

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: mattermost-code <matty-code@mattermost.com>
2026-06-29 12:23:08 -04:00
..