Summary
Tango migrations are currently linear in both contract and execution. That is easy to reason about, but it breaks down once teams produce schema work in parallel across multiple branches.
The first missing foundation is dependency metadata and graph-aware planning.
Current codebase context
packages/migrations/src/domain/Migration.ts only exposes id, mode, up, and down.
packages/migrations/src/runner/MigrationRunner.ts loads migration files and sorts them lexicographically before planning/applying.
plan() and status() both assume the same linear sequence.
Problem
A purely filename-sorted chain works for single-stream development but offers no first-class way to represent:
- one migration depending on two earlier branches
- multiple heads that need an explicit merge point
- cycle detection or missing-dependency diagnostics
Without dependency metadata, merge-aware migration workflows are not really possible.
Proposed implementation plan
- Extend the migration contract.
- Add optional dependency metadata to
Migration in a way that keeps simple linear migrations lightweight.
- Replace file-sort planning with graph-aware planning.
- Topologically sort migrations, detect cycles, and fail clearly on missing dependencies.
- Update runner/status/plan behavior.
- Ensure
apply, plan, and status all reflect the dependency graph instead of a filename-only order.
- Add tests and docs.
- Cover linear back-compat, multiple heads, merge migrations, cycles, and missing dependencies.
Acceptance criteria
- Migrations can declare dependencies beyond simple filename order.
- The runner plans and applies migrations by dependency graph, not just lexicographic sort.
- Missing dependencies and cycles fail with clear diagnostics.
- Existing linear migrations remain supported or have a straightforward migration path.
- Docs explain the new dependency model and how it affects authoring/review.
Summary
Tango migrations are currently linear in both contract and execution. That is easy to reason about, but it breaks down once teams produce schema work in parallel across multiple branches.
The first missing foundation is dependency metadata and graph-aware planning.
Current codebase context
packages/migrations/src/domain/Migration.tsonly exposesid,mode,up, anddown.packages/migrations/src/runner/MigrationRunner.tsloads migration files and sorts them lexicographically before planning/applying.plan()andstatus()both assume the same linear sequence.Problem
A purely filename-sorted chain works for single-stream development but offers no first-class way to represent:
Without dependency metadata, merge-aware migration workflows are not really possible.
Proposed implementation plan
Migrationin a way that keeps simple linear migrations lightweight.apply,plan, andstatusall reflect the dependency graph instead of a filename-only order.Acceptance criteria