Concept: Transition

Abstract

A transition is the set of construction steps that upgrade a database from one version to another. It can upgrade a database from emptiness to the first meaningful version or from any meaningful version to its immediate successor. DataClass organizes transition logic so as to associate it with its target version.

Body

Part of building a database incrementally is arranging its construction steps so that every database passes through the exact same set of versions. The sequence of steps required to a particular version is the transition to that version.

DataClass gives you a tool that allows you to partition your transition logic and keep each set of steps with the version it ultimately produces.

Consider the following code:

You can click on keywords and concepts in blue.
handdatabase SomeDatabase
{
  version 1.0 : initialized
  {
    construction
    {
      step sql
      {
CREATE TABLE X(Y INT);
      }
    }
  }
  version 1.1 : 1.0
  {
    construction
    {
      step sql
      {
CREATE TABLE Z(A CHAR(1));
      }
    }
  }
}

In the previous example, the transition from an empty database to version 1.0 builds the table X and the transition to version 1.1 builds a table Y. DataClass guarantees that these are each executed only once and always in the correct order.

In addition to facilitating DataClass's tamper-resistance features, breaking down construction logic into sequential transitions associated with real-life production versions lays the foundation for transition testing, a major contributor to the autonomation of your database class.

Related Use Cases

Related Concepts

Related Keywords

Other Actions

documentation | all examples | use cases | concepts | keywords