Expand description
All-at-once, reversible migration to the native binary document body (PRD-1398, ADR-0063).
A legacy DOCUMENT store keeps two copies of every document — a plain-JSON
body and the materialised promoted columns. The single-source slices
(#1402/#1403) make the binary body the one source of truth, but existing
stores still hold plain-JSON bodies with promoted columns. This tool
performs the cutover, modelled on the maintainer’s explicit safety margin:
the canonical data is never touched until the very end.
The migration is all-at-once but reversible:
- Read every document from the source store (untouched, read-only).
- Build a fresh store in new files alongside the source, rewriting each
document into the native binary container (
crate::document_body). - Auto-
CREATE INDEXfor every previously-promoted field so queries that relied on the implicit promoted-column filter stay fast — avoiding a silent post-deploy performance regression. - Verify document counts match per collection; any mismatch aborts the migration before the swap, leaving the source store untouched.
- Atomically swap the new files into place and retain the old files as the rollback point.
The unit of migration is a store directory (the directory that holds the
db.rdb data file and its sibling artifacts — WAL, snapshots, audit log).
Swapping whole directories with rename(2) is atomic on POSIX and lets the
pre-migration directory survive untouched as the rollback point.
Structs§
- Collection
Migration - Per-collection outcome of a migration.
- Migration
Report - Summary of a completed, swapped migration.
Functions§
- migrate_
store_ to_ binary_ body - Migrate the DOCUMENT collections of the store in
store_dirto the native binary body, reversibly.