ds migrations
On this page
Defined in cli/commands/migrations.ts. Runs the Drizzle SQL migrations against the bound database, plus a handful of operational repair and inspection scripts that live beside them.
Migrations come in two chains, so a rolling deploy can run old and new Lambda revisions side by side: expansion migrations (additive schema changes, safe for both revisions) and contract migrations (destructive or tightening changes, safe only once every new Lambda is live). The deploy pipeline runs them as two separate steps around the code switch; locally you normally run both at once.
ds migrations run#
ds migrations run
Runs the expansion chain, then the contract chain, bringing the bound database to the latest schema. No flags. This is the everyday local command.
ds migrations run-sql#
ds migrations run-sql
Same as ds migrations run — both call the same function, which runs expansion then contract. The two names are kept for compatibility; prefer run. No flags.
ds migrations run-sql-expand / run-sql-contract#
ds migrations run-sql-expand # additive migrations only — the deploy pipeline's before_deploy step
ds migrations run-sql-contract # tightening migrations only — the deploy pipeline's after_deploy step
The two halves of run, split so Seed can apply the additive schema changes before SST switches Lambda code and the destructive ones only after every new Lambda is live (see Deployment). Locally you rarely need them separately. No flags.
ds migrations repair-time-rollups#
ds migrations repair-time-rollups [--org <organizationId>] [--items I123,I456] [--dry-run] [--limit <n>]
Repairs work-item time rollups that drifted from their completed time entries. It applies by default; --dry-run only reports. --org scopes to one organization, --items to a comma-separated list of item numbers, and --limit caps the rows displayed (default 50) — the repair itself covers every detected row.
ds migrations production-inventory#
ds migrations production-inventory [--verify] [--attest-evidence] [--expiry-days <days>]
Read-only production topology and durability inventory. By default it writes a signed, content-free manifest; --verify checks the committed manifest plus the attested manual evidence and exits 1 on any blocker; --attest-evidence is the owner step that binds the filled evidence file to the current manifest signature. --expiry-days is the manifest freshness window (default 14, the replay-horizon retention).
Publish-intent journal operations#
Four subcommands operate on the publish-intent journal — the durable record of integration events waiting to be published — for incident work. Read them as a set: two inspect, two change state.
| Command | What it does |
|---|---|
ds migrations inspect-publish-intents [--status <status>] [--limit <n>] |
Read-only list of journal rows by status (pending, failed, unknown, quarantined, published; default quarantined). --limit defaults to 50 |
ds migrations stuck-fifo-groups [--min-head-age-minutes <n>] [--limit <n>] |
Read-only list of FIFO groups whose head is wedged non-published and blocking successors, most-blocking first. A head older than --min-head-age-minutes (default 60) is flagged even when it is not quarantined |
ds migrations redrive-publish-intents --ids <csv> [--dry-run] [--include-unknown] [--include-permanent] |
Resets quarantined intents to failed so the dispatcher sends them again, identity preserved. --include-unknown also redrives unknown rows, which is unsafe for EventBridge (they may already be delivered, and have no dedup id) — only with out-of-band reconciliation. --include-permanent also redrives permanently unrecoverable quarantines (a checksum mismatch, say), which is futile until the underlying data or code is fixed |
ds migrations skip-publish-intents --ids <csv> --yes-deployed [--dry-run] |
Terminally marks quarantined intents skipped (deliberately not sending), releasing any FIFO successors they hold. --yes-deployed is required to write: it confirms the release with skipped support is fully deployed, because an older dispatcher keeps blocking behind a skipped head and cannot undo it |
Legacy SQL usage sampling#
ds migrations sample-legacy-sql-usage [--endpoint primary|replica]
ds migrations legacy-sql-usage-report [--days <n>]
Part of the Lane→Status and Folder→Workstream rename: sample-legacy-sql-usage samples pg_stat_statements on the bound stage's primary and replica for legacy table and column names and writes the samples to legacy_sql_usage_samples (it stores no query text; default: both endpoints when they differ). legacy-sql-usage-report prints a per-role report of those samples — first and last seen, calls, names, gaps — over a window of --days (default 7). Together they show whether anything still reads the old names before they are dropped.