liveBook · Manning

Versioning

As explained in Unit Testing Principles, Practices, and Patterns

A source control system records, versions, and manages changes to files such as application code and database definitions.

Version control records and manages changes to application code and database definitions. For database work, treat the schema as regular code and store every update in one source control system. section 10.1

Use version control for database schemas because it provides:

  • A change history for tracing schema state when reproducing production bugs. section 10.1
  • A single source of truth that keeps database changes aligned with regular code. section 10.1
  • A rule that prevents database-structure modifications outside source control. section 10.1

Avoid the model database

A dedicated model database accumulates schema changes, then production deployments compare against it and generate upgrade scripts. This creates competing sources of truth and loses traceable history. Storing schema updates in Git removes that duplication. section 10.1

Figure 10.1. Having a dedicated instance as a model database is an anti-pattern. The database schema is best stored in a source control system.

Compare the dedicated model-database anti-pattern with storing the schema in source control. section 10.1

How Unit Testing Principles, Practices, and Patterns covers it

How deep it goes
Defines history and single-source-of-truth benefits, but defers detailed source-control operations and workflows.
Examples
Contrasts a dedicated model database with Git-managed schema updates and explicit database migrations.
What it assumes
Assumes familiarity with regular code and source control while teaching database schemas as versioned code.
What you can do after
Operate database changes through Git as the authoritative record instead of maintaining a separate model database.
How it connects
Connects database schema with integration testing, database delivery, migrations, and single source of truth.

Also explained in

Compare how 25 books explain versioning →

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.