Strata · API

defineSequence

defineSequence type-checks a sequence where it is defined and returns the same object. A sequence is an id and an append-only list of migrations. A migration’s number is its position in the list, and the sequence’s version is the number of migrations it has.

Sequence
{
  id: 'theatre.app',
  migrations: [
    {
      description: 'Shows',
      steps: [
        {
          kind: 'sql',
          sql: 'CREATE TABLE shows (night date PRIMARY KEY, title text NOT NULL)',
        },
      ],
    },
    {
      description: 'Bookings',
      steps: [
        {
          kind: 'sql',
          sql: 'CREATE TABLE bookings (id text PRIMARY KEY, night date REFERENCES shows, seats int NOT NULL)',
        },
      ],
    },
    {
      description: 'Season passes',
      steps: [
        {
          kind: 'sql',
          sql: 'CREATE TABLE passes (member text PRIMARY KEY, amount_cents int NOT NULL)',
        },
      ],
    },
  ],
}
Returned object === input
true
Output matches the expected value

Runs in this page on the installed package. The input and the expected output are defined by the example.