D Driftless

Install & Initialize

01

Install the standalone static binary and bind Driftless to your migration directory.

curl -fsSL https://get.driftless.db/install.sh | sh
driftless init --migrations ./db/migrations --pg-version 16
  • — Generates .driftless.toml with default lock_timeout = '150ms' and statement_timeout = '4s'.
  • — Never modifies pg_catalog or installs superuser C extensions on target hosts.

Lint Pull Requests

02

Detect full-table rewrites, missing CONCURRENTLY keywords, and unvalidated constraints.

driftless lint ./db/migrations/20261127_alter_ledger.sql \
  --catalog-dsn "$READ_REPLICA_DSN" \
  --fail-on-lock ACCESS_EXCLUSIVE
  • — Reads live pg_class row estimates from a read replica to separate safe small-table DDL from rewrite hazards.
  • — Emits SARIF output natively for GitHub Code Scanning.

Execute Shadow Rollout

03

Run an online table rewrite with adaptive throughput throttling and atomic cutover.

driftless apply ./db/migrations/20261127_alter_ledger.sql \
  --strategy shadow-logical \
  --max-replica-lag 400ms \
  --lock-timeout 150ms \
  --keep-reverse-delta 6h
  • — Requires wal_level = logical and a primary key or unique NOT NULL replica identity.
  • — Checkpoints backfill progress every 50,000 rows so interrupted runs resume cleanly.

Sub-Second Rollback

04

Revert a cutover migration without losing writes committed after the swap.

driftless rollback --migration 20261127_alter_ledger --lock-timeout 150ms
  • — Drains the reverse-delta stream into the preserved original table before renaming OIDs back.
  • — Original table is dropped automatically after the retention window expires.