Public repository: timo / mitch

Reader

A migration stitcher (therefore mitch) for PostgreSQL, SQLite, MariaDB, and others

mitch / docs / adr / project / global-project-ids-with-local-aliases.md · 1.6 KB · at 76a2c3d332a1 · raw


status: accepted

Projects have a global ID and are linked under a local alias

A project's ID in mitch.toml is meant to be globally unique, like an npm package name, a Java package or a UUID, and it is what deployments record. A project that links another one names it with a freely chosen alias, and qualified IDs (alias:migration) use that alias. Humans see aliases in status and log; the bookkeeping tables see only IDs.

We chose this over "the alias must equal the project ID" because the same project may be linked along several paths. Example: P links A and B, and both link a utilities project U, possibly under different aliases and from different checkouts. That is allowed and U is applied once. Consistency is enforced by content instead of by name: if two copies of U carry the same migration with different content, loading fails.

Consequences

  • Projects are deduplicated by ID when loading. Links between projects may therefore form cycles; only the migration graph must be acyclic.
  • Only direct links are addressable. A migration in P cannot reference U unless P links U itself, even if U is reachable through A.
  • Addressing and display differ. A migration of U reached through A is shown as a:u:y when that is the only path to it, and under U's project ID when several paths lead to it, because then no alias path is canonical.
  • If two copies of U differ only in which migrations they contain, the sets are united. Two copies conflict only when the same migration ID has a different normalized hash, the same rule that defines a modified migration.