Skip to content

fix(database): reject duplicate migration numbers - #158

Merged
PiquelChips merged 1 commit into
mainfrom
fix/unique-migration-versions
Oct 22, 2026
Merged

PiquelChips merged 1 commit into
mainfrom
fix/unique-migration-versions

Conversation

@PiquelChips

Copy link
Copy Markdown
Member

Two open PRs that each add the next migration (say 0009_a.sql and 0009_b.sql) merge without a git conflict. Nothing checks migration numbers: sqlx embeds both, and once both are on main every database test fails with VersionMismatch(9), which doesn't point at the cause.

This adds a unit test over the embedded migrator: versions must count up from 1 with no gaps or repeats. A rebased branch whose migration collides now fails with:

migration 9 (b) should be numbered 0010; renumber it after the latest migration on main

run_migrations and the test share one MIGRATOR static, so the test checks exactly what ships. The database architecture doc notes the rule.

The Main CI ruleset now also requires branches to be up to date before merging, so a PR that was green before another migration landed has to rebase, and hit this test, before it can merge.

Note

Written by Claude Opus 5.5 in Claude Code (via T3 Code)

🤖 Generated with Claude Code

Two branches that each add the next migration under different file names
merge without a git conflict. sqlx accepts both, and every database test
then fails with an unrelated-looking VersionMismatch. A unit test over the
embedded migrator now requires versions to count up from 1 without gaps
or repeats, and names the migration to renumber.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 22, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 54 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3a1a9649-5cb0-4ab0-a77a-11cd68182863
📥 Commits

Reviewing files that changed from the base of the PR and between 01a0608 and 39b6202.

📒 Files selected for processing: 3
  • crates/database/src/connection/mod.rs
  • crates/database/src/connection/tests.rs
  • docs/architecture/database-crate.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@PiquelChips PiquelChips self-assigned this Oct 22, 2026
@PiquelChips PiquelChips added bug Something isn't working ci-cd CI-CD labels Oct 22, 2026
@PiquelChips PiquelChips added this to the 0.1 milestone Oct 22, 2026
@github-project-automation github-project-automation Bot moved this to Needs Triage in sourceorigin.dev Oct 22, 2026
@PiquelChips PiquelChips moved this from Needs Triage to Ready in sourceorigin.dev Oct 22, 2026
@PiquelChips
PiquelChips enabled auto-merge (squash) October 22, 2026 23:05
@PiquelChips
PiquelChips merged commit 0ef4275 into main Oct 22, 2026
11 checks passed
@PiquelChips
PiquelChips deleted the fix/unique-migration-versions branch October 22, 2026 23:08
@github-project-automation github-project-automation Bot moved this from Ready to Done in sourceorigin.dev Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ci-cd CI-CD

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant