Read-only export of projax.items + projax.item_links to a JSON file the
mBrian-side migration script (m/mBrian#73) consumes. First implementation
slice of the Phase 6 mBrian-backend migration.
Tool:
- cmd/projax-snapshot/main.go: standalone binary, takes --out flag
(default ./projax_snapshot.json). Reads PROJAX_DB_URL or
SUPABASE_DATABASE_URL like the main projax binary.
- Pure read-only: SELECT FROM projax.items WHERE deleted_at IS NULL
+ SELECT FROM projax.item_links. No writes, no schema changes.
- Re-runnable: each invocation produces a fresh deterministic file;
no state, no DB side effects.
Output shape (Snapshot struct):
- version: "1" — bumped on shape changes for downstream version-pinning.
- generated_at: timestamp.
- items: every live projax.items row with all columns mapped 1:1 to
JSON-friendly types (uuid → string, jsonb → map, timestamptz →
RFC3339). Empty slices coerced to [] so the mBrian-side script doesn't
see null-array surprises.
- links: every projax.item_links row, ordered by item_id + ref_type
for stable diffs across runs.
- spot_checks: the 5 representative items the mBrian-side script
verifies post-migration per m/mBrian#73 §3. Selected at runtime by
characteristic (root area, single-parent, multi-parent, caldav-linked,
public-listing-populated) so the picks self-update as the dataset
evolves.
Smoke-tested against the live msupabase dataset:
wrote /tmp/projax_snapshot.json — 65 items, 81 links, 5 spot-checks
Selected spot-checks (live):
dev — root area
paliad — single-parent project
services — multi-parent (2 parents)
mhome — caldav-list-linked
fdbck — public-listing populated
Out of scope (slices B+ pick up):
- The mBrian-side script itself lives in m/mBrian per "mbrian must own
the migration" (Q4=(a)).
- projax-side adapter rewriting waits on the mBrian-side migration run.
- No tests yet: this is a one-off helper against live data; smoke run
above is the validation surface. A go-test suite can land if the
snapshot shape needs evolution before mBrian-side consumes it.