liveBook · Manning

Incremental DDL script

As explained in Test Driven: Practical TDD and Acceptance TDD for Java Developers

An incremental DDL script is a small database schema change that can be applied as a step in an ordered sequence of changes.

Database changes are harder to roll back than application code because a database holds both its schema and its data. Incremental DDL scripts split schema changes into small, ordered steps that can often be reversed without discarding stored data. section 6.4.2

Figure 6.6. Example directory structure with a set of delta change scripts for creating the database schema incrementally. The four scripts in the directory src/db/deltas will be applied in order according to the numerical prefix.

A directory of four numerically prefixed delta scripts illustrates how small schema changes can be applied in order. section 6.4.2

Listing 6.17. Example delta script with an @UNDO-block for rollback

An example delta script includes an @UNDO block for reversing a change. section 6.4.2

How Test Driven: Practical TDD and Acceptance TDD for Java Developers covers it

How deep it goes
Defines schema changes as ordered patches, explains reversibility, and illustrates numbered scripts and an undo block.
Examples
Shows four numerically prefixed delta scripts and an example script with an @UNDO block.
What you can do after
Apply schema changes as ordered deltas and revert newer versions without recreating the database or losing its data.
How it connects
Connects DDL scripts with database schemas, database rollback, and database migrations.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Test Driven: Practical TDD and Acceptance TDD for Java Developers. The section links point to the parts of the book it draws on.