Database Migration
A versioned, ordered change to a database schema, applied once and recorded.
A database migration is a versioned script that changes a schema, applied in order and recorded so it runs exactly once per environment. Migrations are how a schema evolves without anyone hand-editing production.
The discipline has a few unforgiving rules, most of which are learned by violating them.
A migration that has run anywhere is frozen. Editing or renaming it does nothing to the environments that already recorded it, so their schema no longer matches any file. Changes must be appended.
Order is the whole mechanism, and ordering is by name. An appended migration must sort into the right place — and if the sequence includes a data-seeding step, a schema addition must sort before it, because a data layer's insert typically names every column in its current model and a fresh environment will fail on a column that does not yet exist.
Reversal is often a lie. A down migration that deletes data cannot distinguish seeded data from authored data, so refusing to run is more honest than guessing. And bulk deletion inside a migration transaction can hang indefinitely rather than failing.
The only verification that proves any of this is running the real path: reset, migrate, build, start in production mode, and request the result.
See also5
Relational Database
Data organized as tables with declared relationships, queried declaratively and guarded by constraints.
Data & Content13 connections
Seed Data
Initial content created programmatically to make an empty system usable or demonstrable.
Data & Content8 connections
Continuous Deployment
Automatically releasing every change that passes validation.
Version Control & Delivery15 connections
Idempotence
The property that performing an operation twice has the same effect as performing it once.
Systems & Tooling23 connections
Schema Drift
Divergence between a schema and the code, types, or documentation that describe it.
Data & Content11 connections
Related3
Nearby in the graph rather than deliberately chosen. Looser, sometimes surprising.
Linked from10
- Blue-Green DeploymentVersion Control & Delivery
Running two identical production environments and switching traffic between them instead of upgrading one in place.
- Continuous DeploymentVersion Control & Delivery
Automatically releasing every change that passes validation.
- Filesystem SnapshotSystems & Tooling
A point-in-time, near-free copy of a filesystem's state, made possible by sharing unchanged blocks with the live data.
- IdempotenceSystems & Tooling
The property that performing an operation twice has the same effect as performing it once.
- Relational DatabaseData & Content
Data organized as tables with declared relationships, queried declaratively and guarded by constraints.
- RollbackVersion Control & Delivery
Reverting a running system to a previous known-good version, as distinct from fixing forward.
- Rolling ReleaseSystems & Tooling
A distribution model that ships updates continuously instead of in versioned batches, trading stability for currency.
- Schema DriftData & Content
Divergence between a schema and the code, types, or documentation that describe it.
- Seed DataData & Content
Initial content created programmatically to make an empty system usable or demonstrable.
- Zero-Downtime DeploymentVersion Control & Delivery
Deploying a new version while the service keeps serving every request, with no maintenance window.