Strata · Migrations

Cross-sequence order (dependsOn)

dependsOn lists migrations of other sequences that must be applied before a migration runs. By default sequences run in the order they are passed, each sequence’s migrations in their own order. Here the table of theatre.door/1 references bookings, so the migration depends on theatre.app/2 and is ordered last, although its sequence is passed first.

Dependent sequence (door)
{
  id: 'theatre.door',
  migrations: [
    {
      description: 'Who was let in',
      dependsOn: ['theatre.app/2'],
      steps: [
        {
          kind: 'sql',
          sql: 'CREATE TABLE admitted (booking text PRIMARY KEY REFERENCES bookings)',
        },
      ],
    },
  ],
}
APP (descriptions only)
{
  id: 'theatre.app',
  migrations: ['Shows', 'Bookings', 'Season passes'],
}
Call (empty ledger)
planMigrations(await prepare([door, APP]), [])
Pending, in run order
[
  'theatre.app/1',
  'theatre.app/2',
  'theatre.app/3',
  'theatre.door/1',
]
Output matches the expected value

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