Skip to content

CI: migrations can't collide or be renamed (sc-9611) - #262

Open
ndbroadbent wants to merge 2 commits into
ci-lintfrom
ci-migrations
Open

ndbroadbent wants to merge 2 commits into
ci-lintfrom
ci-migrations

Conversation

@ndbroadbent

@ndbroadbent ndbroadbent commented Dec 5, 2026 •

Copy link
Copy Markdown
Member

Sixth PR for sc-9611: migrations can't collide. It's stacked on #261 and retargets as the stack merges.

laravel-rust runs migrations in file-name order and records each by name (laravel-rust-database 0.1.4: the macro sorts the files, and pending() skips the names already recorded). New script scripts/ci/check_migrations.sh (ported from fleetlayer's scripts/check-migrations, adapted to timestamped names) checks three things, in the cli-version job beside migration_safety.py:

  • Name: every file in app/database/migrations/ is YYYY_MM_DD_HHMMSS_snake_case.rs.
  • Never renamed or removed: every migration on the base commit is still there under the same name. Deployed databases may have applied it, so a rename would run it a second time.
  • New ones sort last: each new migration sorts after every migration on the base. Two branches that each add one: whoever merges second takes a later timestamp. Otherwise production runs theirs after the newer one, while fresh databases (CI, dev) run it before, so the two schemas can end up different.

Shared timestamps (three 2026_12_06_000000_* today) aren't collisions: the names differ, and the rest of the name orders them.

It starts green: 20 migrations, all named right, and nothing new against main. AGENTS.md says how to name one.

Checked locally, with planted cases: an older-dated new migration, a renamed one, and a badly named file each exit 1 with a message saying what to do.


Get evidence
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…ied migrations fail, unreachable base warns (review)

This branch has not been deployed

No deployments
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