I maintain several codebases that need overlapping subsets of the same migrations, for example user management with or without groups. Today a migration can only depend on migrations of its own project. Nested projects are loaded since the last commit, but every command ignores them, so their migrations are never applied and cannot be referenced. Sharing migrations therefore means copying files between projects, and the copies drift apart.
Solution
A project can link other projects and depend on individual migrations from them. Linked projects are found automatically when nested, or declared with an alias and a path in mitch.toml when they live elsewhere, for example in a git submodule or a Mercurial subrepository that the codebase delivers itself. A migration references a linked migration by its qualified ID alias:migration.
mitch up applies all of the project's own migrations plus exactly the linked migrations they transitively require, nothing more. The deployment records which applied migration depends on which. That lets down and drop clean up linked migrations nobody needs any more, and lets mitch refuse to revert something another project on the same deployment still builds on. The same linked project may arrive along several paths and under different aliases; it is applied once, and mitch fails loudly if two copies disagree on a migration's content.
User Stories
As a developer, I want to declare a linked project in mitch.toml under an alias with a relative path, so that I can depend on migrations from a sibling checkout or a submodule.
As a developer, I want a project nested in my project's directory to be linked automatically under its directory name, so that the common case needs no configuration.
As a developer, I want an explicit declaration to override the alias of a nested project, so that I can pick a readable alias.
As a developer, I want an error when two nested projects would get the same alias, so that a qualified ID never becomes ambiguous.
As a developer, I want an error naming the alias and the expected path when a declared linked project has no mitch.toml there, so that I notice an uninitialized submodule immediately.
As a developer, I want status to report a missing linked project as a warning instead of failing, so that I can still inspect the deployment.
As a migration author, I want to list alias:migration in dependencies, so that my migration builds on a migration from a linked project.
As a migration author, I want unqualified IDs to always mean my own project, so that existing configs keep their meaning.
As a migration author, I want migration IDs to keep allowing slashes, so that IDs derived from file paths still work.
As a migration author, I want an error when an alias contains a colon, so that qualified IDs stay parseable.
As a migration author, I want create --dependency alias:migration to validate the reference against the linked project, so that typos fail early.
As a migration author, I want an error when I reference a project that is only linked transitively, so that my project does not break when a linked project drops one of its own links.
As an operator, I want up to apply my project's migrations plus all linked migrations they transitively require, so that one command brings a deployment up to date.
As an operator, I want up to leave linked migrations alone that nothing requires, so that a deployment only gets what it needs.
As an operator, I want add to reject qualified IDs with an explanation, so that linked migrations only arrive as dependencies of my own migrations.
As an operator, I want drop to accept qualified IDs and revert the linked migration together with all its loaded dependants, so that I can get rid of a linked migration I requested.
As an operator, I want down to also revert linked migrations that become orphaned, so that down restores the deployment to its state before up.
As an operator, I want drop of my own migration to also revert linked migrations that it alone required, so that no orphans remain.
As an operator sharing a deployment between projects, I want a revert to be refused when an applied dependant belongs to a project that is not loaded, with the blocking project IDs and migrations listed, so that I never break another project's schema.
As an operator sharing a deployment between projects, I want my down to keep a linked migration that another project still depends on, so that projects can share linked migrations safely.
As an operator, I want linked migrations recorded under their project ID rather than my alias, so that every project on the deployment sees the same records.
As a developer, I want the same linked project reached via several paths to be applied once, so that diamond-shaped links work.
As a developer, I want different linking projects to be free to use different aliases for the same project, so that aliases stay a local choice.
As a developer, I want loading to fail when two copies of a linked project contain the same migration ID with different normalized hashes, naming both paths, so that inconsistent copies never reach a deployment.
As a developer, I want copies that only differ in which migrations they contain to be merged, so that a newer copy in one place does not block an older one elsewhere.
As a developer, I want links between projects to be allowed to form cycles, so that two teams can depend on each other's migrations as long as the migration graph stays acyclic.
As a developer, I want an error for a cycle in the migration graph across projects, so that impossible orders are caught.
As a developer, I want status to list required linked migrations under their alias path when there is exactly one path, so that they read naturally.
As a developer, I want status to list a required linked migration under its project ID when it is reachable via several paths, so that the display is never ambiguous.
As a developer, I want status to hide linked migrations that are not required, so that the output only shows what concerns my project.
As a developer, I want status --all to also show the non-required migrations of directly linked projects, so that I can see what a linked project offers.
As a CI pipeline, I want status exit codes to account for pending and modified required linked migrations, so that a pipeline catches them.
As a CI pipeline, I want missing to be reported only for my own project's migrations, so that another consumer's newer copy of a linked project does not fail my build.
As a developer, I want log to show my project's and the required linked migrations with the same naming rules as status, so that both views agree.
As an operator, I want the recorded dependency edges of my project's applied migrations refreshed from the source on every run, so that the deployment's view of who needs what stays current.
As a migration author, I want a dependency I removed from an applied migration to disappear from the deployment without further action, so that the formerly required linked migration can be cleaned up.
As a migration author, I want a dependency I added to an applied migration, whose target is not applied, to make that migration count as modified, so that the existing --if-modified policy decides what happens.
As a migration author, I want a flag that instead applies the newly added dependency late and keeps the dependant, with a warning, so that I can document an implicit dependency without a redeploy.
As an operator, I want own and linked migrations batched into transactions regardless of project boundaries, so that a run is as atomic as it is today.
As a developer, I want checkout to warn when a linked project's content differs between the current and the target commit, for git submodules and Mercurial subrepositories, so that I know to run status or up afterwards.
As a developer, I want init to reject empty project IDs and IDs containing whitespace, so that IDs stay usable as global names.
Implementation Decisions
Glossary and ADRs. The vocabulary is defined in CONTEXT.md: project ID, linked project, alias, qualified ID, required migration, orphaned migration. The decisions are recorded in the ADRs project/global-project-ids-with-local-aliases, project/project-ids-are-immutable, project/code-delivery-is-out-of-scope, runner/multiple-projects-per-database and runner/deployments-record-the-applied-dependency-graph. The term "subproject" is replaced by "linked project" in code.
Project configuration.mitch.toml gains an optional [projects] table mapping alias to a path relative to the project root. Nested projects are still discovered while walking the directory. An explicit entry for the same directory overrides the directory-name alias. Alias collisions, missing mitch.toml at a declared path, and aliases containing a colon are load errors.
Loading model. Loading a project yields a graph of projects keyed by project ID, deduplicated by ID, so link cycles and diamonds terminate. Each project keeps its own alias map, which resolves qualified references written inside it. Reloading rebuilds this from scratch instead of accumulating.
Copy consistency. When the same project ID is loaded from several paths, migrations are merged by migration ID. A shared ID with a different normalized hash is a load error naming both paths. The normalization is the one the runner already uses for modification detection.
Migration identity. A migration is identified by the pair of project ID and migration ID. Qualified references are split at the first colon. The alias is resolved only in the referencing project's own alias map, so transitive references are an error.
Combined graph. Dependency resolution, topological ordering, and the dependants lookup work across all loaded projects. The tie-break for independent migrations includes the project ID, so the order is deterministic.
Required set.up computes the own migrations plus the transitive dependency closure. add restricts its targets to own migrations. drop accepts own and qualified targets.
Deployment schema. A new bookkeeping table stores edges from an applied migration to the migration it depends on, each side as project registry key plus migration ID. The table has a column for the edge kind, so ordering constraints from the rework spec fit in. Edges are written on apply and removed on revert. On every run they are refreshed for the applied migrations of all loaded projects. Edges of projects that are not loaded stay untouched.
Revert planning. Dependants are taken from the source graph and from stored edges. If a stored edge's dependant belongs to a project that is not loaded, the revert is refused with an error listing those projects and migrations. There is no force option. After a revert, linked migrations with no remaining applied dependants are orphaned and reverted in the same run.
Modification detection. An applied migration counts as modified also when its source declares a dependency on a migration that is not applied. A new up flag applies such dependencies late with a warning. Removed dependencies only refresh the edges.
Display. A single naming function renders a migration for humans: the bare ID for the own project, the alias path when exactly one path leads to it, otherwise the project ID followed by the migration ID. status and log both use it. missing is computed only for the own project.
Checkout. The VCS managers detect changed submodule or subrepository pointers between the two commits and print a warning. No database action follows from it yet.
Error types. New errors cover alias collision, missing linked project, conflicting copies, transitive reference, migration-graph cycle, and blocked revert. Each message names the projects and paths involved.
Testing Decisions
Good tests drive mitch through the CLI and assert on what a user can observe: exit codes, output lines, the schema objects in the database, and the bookkeeping tables. They do not reach into the loader's or the runner's internals.
Seam. The CLI, invoked in-process as the existing tests do, against SQLite database files and git repositories created under the test's temporary directory. Loading errors are also observed through the CLI, for example via status.
A small test helper builds multi-project layouts with nested and declared links, diamonds and cycles, so that each test states its topology in a few lines.
Prior art: the checkout, status and log tests in the CLI test module, and the helpers there that initialize git repositories and write project configs. Two linked projects in different repositories need the same helpers twice.
Scenarios to cover: diamond with matching copies, diamond with conflicting copies, link cycle, transitive reference error, up applying only the required set, down cleaning orphans, revert refused because of an unloaded project's dependant, added and removed dependencies on applied migrations, the display rules, and missing restricted to the own project.
Out of Scope
Fetching, pinning or updating linked projects. Delivery stays with git submodules, Mercurial subrepositories or similar.
Renaming project IDs, including any former_ids mechanism.
Reverting or applying linked-project changes during checkout. Only the warning is in scope.
Rework, rebuild, ordering constraints, and the ID-based checkout plan, which are covered by the rework spec.
Recording exact apply order for reproduction (freeze), squash, destructive markings, and multiple deployments per run.
Further Notes
The rework spec builds on the edge table introduced here, so this spec should land first.
Existing project IDs like the test fixtures' stay valid. Free-form IDs are allowed, and global uniqueness is a convention, not something mitch can check.
Transferred from the former GitLab tracker (0814/mitch#1, opened 2026-11-05, closed 2026-11-05). Implemented in commit 1fb3add "Link projects and depend on their migrations across projects".