liveBook · Manning

State-based database delivery

As explained in Unit Testing Principles, Practices, and Patterns

State-based database delivery represents the desired database schema as a complete target state and updates databases to match it.

State-based database delivery stores SQL scripts describing the desired database schema in source control. During deployment, a comparison tool examines the production database and generates the changes needed to match that target state. section 10.1

The approach makes the database state explicit while leaving the transition implicit:

  • A model database is represented by scripts that create its tables, views, indexes, stored procedures, reference data, and other schema elements. section 10.1 section 10.7
  • The comparison tool performs the synchronization, potentially deleting unnecessary tables, creating new ones, or renaming columns. section 10.1
  • Compared with migration-based delivery, this approach simplifies explicit state management but makes data motion harder to control; explicit migrations are preferred for that reason. section 10.1 section 10.7

How Unit Testing Principles, Practices, and Patterns covers it

How deep it goes
Explains source scripts, comparison-driven synchronization, and trade-offs, but stops short of detailing comparison-tool implementation.
Examples
Uses SQL creation scripts, production-schema comparisons, table deletion, table creation, and column renaming.
What it assumes
Assumes familiarity with database schemas, deployments, source control, and production databases.
What you can do after
Evaluate state-based delivery against migration-based delivery, especially for controlling data motion.
How it connects
Connects database schema, source control, comparison tools, and migration-based delivery.

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.