zmdbzero-maintenance data layer
Docs Benchmarks Anti-patterns OpenAPI
Docs / Build an application

upSupported

Applying migrations#

Use the packaged command:

yarn zmdb migrate

The public runner keeps up as its library verb:

import { driverMigrationConnection, up } from '@zmdb/migrations/runner';
import { sqlite } from '@zmdb/sqlite';

const connection = driverMigrationConnection(driver, sqlite);
await up(connection, migrations);

It reads the checksum-aware ledger, verifies every applied migration it can verify, and applies pending versions in ascending order. The driver adapter keeps each Postgres or SQLite migration body and ledger write in one transaction.

zmdb up exits 2 and names both alternatives. Reusing the word for snapshot rewrites would make a typo choose between filesystem and database mutation.

Rollback and status#

The executable exposes the other two runner operations under explicit names:

yarn zmdb status
yarn zmdb rollback
yarn zmdb rollback --to 20260904010101

rollback without --to reverts the highest applied version. With --to, it reverts every newer version and leaves the target applied.

Upgrading a stored snapshot#

yarn zmdb upgrade

Snapshot format version 1 is the only format this build knows. Running upgrade against it returns changed: false and does not touch the file's mtime. A snapshot from a newer build is an invocation error rather than an attempted downgrade. No older snapshot shape is frozen yet, so this build does not invent a conversion for one.

The current-format fixture and the deliberately refused alias produced:

$ yarn zmdb upgrade
/workspace/shop/zmdb.config.ts
snapshot is already at version 1

$ yarn zmdb up
zmdb up: `up` is not a command; use `migrate` to apply migrations or `upgrade` to rewrite a stored snapshot
$ echo $?
2

---

See also: migrate · Migration Runner · CLI Overview