migrate / audit
01 — Five tables
History as data, not log lines.
Five real Postgres tables — no sidecar service. Every applied migration writes rows you can query with plain SQL, replay with migrate history --verbose, or diff across releases.
Each table has its own shape.
_zanith_migrationsApplied migration IDs and applied_at. The ledger of what ran.
2 columns_zanith_migration_stepsPer-op audit: status, SQL, risk level + score, error. The black box.
10 columns_zanith_schema_snapshotsFull SchemaGraph JSON after each migration (`after` phase). Replay the shape at any point.
4 columns_zanith_migration_artifactsRecovery artifacts: type, source, physical name, checksum, recovery SQL, expiry.
13 columns_zanith_migration_checkpointsResumable backfill cursor + processed rows + status. Crash-safe progress.
7 columnsReconstruct any past state.
snapshot · after apply
1,000 models · 3,967 relation edges
proof suite large-schema stress (RESULTS.md §1)
Each migration prints per-step sigils (✓ ✗ ↻), risk level, and snapshot: N model(s) from _zanith_schema_snapshots. Snapshots are stored as JSON — diff any two to see exactly what changed between releases.
Six questions your audit tables answer.
What broke this week?
Failed steps in the last seven days — migration id, op kind, and the refusal reason.
| migration_id | operation_kind | error |
|---|---|---|
| 20260402_drop_legacy_uuid | dropColumn | refused — max risk 60 |
Which op kinds are slowest?
Average duration per operation kind on this database — spot the expensive patterns.
| operation_kind | avg_ms | runs |
|---|---|---|
| addIndex | 612 | 14 |
| backfill | 178 | 6 |
| addColumn | 84 | 22 |
What's still recoverable?
Live artifacts with no expiry — the rows recover list reads.
| id | artifact_type | row_count |
|---|---|---|
| …::archive_column::p5_legacy.legacy_code | archive_column | 5 |
The ledger records it all. See what writes to it.
These tables are filled by every other stage. Here's where the writes come from.
Lifecycle, in depth
Generate, plan, verify, apply, audit — every flag, every output, every artifact path.
/migrate/lifecycleRisk model
6 levels, 21 reason codes, 7 gates, 31 op kinds. The full classifier.
/migrate/riskShadow-DB verify
The 4 internal stages of verifyOnShadow, deployment topologies, 4 verdicts.
/migrate/verifyRecovery
5 artifact kinds, the bookkeeping table, the 7-verb recover CLI.
/migrate/recoverelsewhere