Skip to content

Conversation

@aoengin
Copy link

@aoengin aoengin commented Jan 4, 2026

What / why

When embedding migrations into the binary via migrate!, the iteration order of migration files can vary across filesystems/OSes. That makes the resulting embedded migration list (and thus the final binary) non-deterministic, which breaks reproducible builds.

This PR makes migration ordering deterministic by explicitly ordering reversible migration pairs so that up is always before down for the same migration version.

Changes

  • Add MigrationType::direction_order() to define a stable tie-break rule (up/simple first, down second).

  • Update Migrator::with_migrations() to sort migrations by:

    1. version ascending
    2. then direction_order() for version ties.
  • Apply the same deterministic sort when resolving migrations from a source (blocking resolver).

Impact

  • Not a breaking change: applied migrations and version ordering remain the same; only the deterministic ordering of reversible pairs is enforced.
  • Fixes non-determinism in builds that embed migrations.

@aoengin aoengin marked this pull request as draft January 4, 2026 11:05
@aoengin aoengin marked this pull request as ready for review January 4, 2026 12:00
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