Strata · API

checksumOf

checksumOf returns the SHA-256 checksum of a migration’s steps, which is the value the ledger records. The description, dependsOn and full-line -- comments are excluded, so rewording an applied migration keeps its checksum and editing a step changes it.

Migration
{
  description: 'Season passes',
  steps: [
    {
      kind: 'sql',
      sql: 'CREATE TABLE passes (member text PRIMARY KEY, amount_cents int NOT NULL)',
    },
  ],
}
Migration: reworded
{
  description: 'A season pass, and what it is charged',
  steps: [
    {
      kind: 'sql',
      sql: '-- one row a member
CREATE TABLE passes (member text PRIMARY KEY, amount_cents int NOT NULL)',
    },
  ],
}
Migration: SQL edited
{
  description: 'Season passes',
  steps: [
    {
      kind: 'sql',
      sql: 'CREATE TABLE passes (member text PRIMARY KEY, amount_cents int NOT NULL DEFAULT 8900)',
    },
  ],
}
Checksums
{
  written: '1c4f97e8b1cd64f052bd05eab5000f3bbfd02c93e57f2791a3e517b8b69659f8',
  reworded: '1c4f97e8b1cd64f052bd05eab5000f3bbfd02c93e57f2791a3e517b8b69659f8',
  edited: 'd097bac0fbc0a97ea9166af6ad67c31116c56f99d086ff55163fc658a53db273',
}
Output matches the expected value

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