liveBook · Manning

Migration-based database delivery

As explained in Unit Testing Principles, Practices, and Patterns

Migration-based database delivery represents database schema changes as ordered migrations applied incrementally over time.

Migration-based database delivery represents schema changes as explicit, ordered migrations that move a database from one version to another. Store these migrations with regular code in source control, creating a single source of truth and preserving change history. section 10.0 section 10.1

Prefer this approach because it:

  • Makes each schema transition visible rather than deriving it implicitly from differences between database states. section 10.7
  • Handles data motion more effectively, which outweighs the easier merge-conflict handling offered by state-based delivery. section 10.7
  • Requires every schema and reference-data modification to pass through a migration. section 10.7

An explicit migration

A migration named CreateUserTable defines an Up operation that creates the Users table and a Down operation that deletes it. The paired operations make the transition and its reversal concrete.

How Unit Testing Principles, Practices, and Patterns covers it

How deep it goes
Defines explicit version transitions and contrasts them with implicit state comparison, emphasizing data motion over merge conflicts.
Examples
Uses a CreateUserTable migration with paired Up and Down operations to create and delete a table.
What it assumes
Assumes familiarity with database schemas and source control while treating schema changes as regular code.
What you can do after
Apply schema and reference-data changes through ordered migrations stored alongside application code.
How it connects
Connects database schema, source control, reference data, state-based delivery, and data motion.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Unit Testing Principles, Practices, and Patterns. The section links point to the parts of the book it draws on.