Mitch
Mitch manages database schema migrations as a graph of patches that depend on each other, so that several codebases can share a subset of the same migrations (user management with or without groups, for example) instead of maintaining one strict sequence per codebase.
Language
Structure
Project:
A directory with a mitch.toml whose migrations form a directed acyclic graph. The unit of sharing between codebases.
Avoid: Repository (reserved for the version-control checkout a project lives in)
Project ID:
The globally unique, stable name of a project, chosen like a package name (de.nullachtvierzehn.user-management) or a UUID. Deployments record applied migrations under it, so it never changes once deployed.
Avoid: Project name
Linked project:
Another project whose migrations a project may depend on. It is found either by nesting (a directory with its own mitch.toml inside the project) or by an explicit declaration in mitch.toml for paths outside the project. The same project may be linked several times along different paths (two linked projects both linking a shared utilities project); it is still one project.
Avoid: Subproject (suggests ownership), vendor project, dependency project
Alias: The local name under which a project refers to one of its directly linked projects. Freely chosen by the linking project; two projects may use different aliases for the same linked project. Shown to humans instead of the project ID.
Qualified ID:
A migration ID prefixed with an alias and a colon, users:create-users. An unqualified ID always refers to the project it is written in. Only directly linked projects can be addressed this way. Aliases must not contain a colon; migration IDs may contain slashes because they are derived from file paths.
Required migration: A migration that a project needs on a deployment: every migration of the project itself, plus every migration they transitively depend on, whether local or from a linked project. Migrations of a linked project that are not required are left alone unless asked for explicitly.
Migration: One patch to a database schema: an up script, an optional down script, and metadata (ID, creation time, dependencies, transactional, idempotent). Identified by its ID within its project. Avoid: Change, changeset, patch, version, script
Pulled-in migration: A migration of a linked project that a deployment got only because one of a project's migrations depends on it. A migration a project applies as one of its own is never pulled in, even if other projects link to it. Avoid: Implicit migration, foreign migration
Orphaned migration: A pulled-in migration that no applied migration on the deployment depends on any more. It is reverted together with the last migration that required it.
Up script / Down script: The SQL that applies a migration, and the SQL that reverts it. A migration without a down script cannot be reverted. Avoid: Forward/backward script, deploy/revert script
Dependency: A migration that must be applied before another one. The inverse is a Dependant. Avoid: Requirement, prerequisite, parent/child
Ordering constraint:
A declaration that a migration runs after certain others whenever those are applied on the deployment or part of the same run, without requiring them. Declared as after, in contrast to a dependency, which also pulls its target onto the deployment.
Avoid: Soft dependency, optional dependency, weak dependency
Rework: A new version of an existing migration. The edited file stays at the old path and gets a new ID; the previous version is archived under its original ID. The new version depends on the previous one, so every deployment, old or fresh, runs the previous version first and the new one on top of it. Avoid: Edit, amend, supersede, replace
Rebuild: Reverting the applied dependants of a migration, applying a migration, and re-applying those dependants. Used when a change cannot be made while dependent objects exist, such as recreating a view that policies or materialized views build on. Avoid: Cascade, recreate
Databases
Deployment: A concrete database that migrations are applied to, identified by a connection URL. Avoid: Target, environment, database (when the role in mitch is meant, not the engine)
Apply / Revert: Running a migration's up script on a deployment and recording it there; running its down script and removing the record. Avoid: Deploy, undeploy, add, drop, rollback (these are CLI command names, not domain terms)
Status: What a deployment knows about a migration: pending (not applied), applied (applied and unchanged), modified (applied, but the up script has changed since), missing (recorded as applied, but no longer present in the project). Avoid: State, deployment status
Transactional migration: A migration whose statements may run inside one transaction together with neighbouring transactional migrations. A non-transactional migration runs alone in autocommit mode.
Idempotent migration: A migration whose up script reaches the same state whether none, the same or any earlier version of it is already applied on the deployment. Marking a migration idempotent is the author's promise.
Version control
Checkout: Switching the version-control branch while keeping the deployment consistent with the migrations present on the new branch.
Stash: Setting aside uncommitted migration changes while reverting their effect on the deployment, so that both can be restored later.