Expand description
Stepwise schema migration for block-stored JSON.
When a block’s crate::Block::version is bumped, every load
comparing the stored version on a JSON entry to the current
version triggers apply_migrations, which walks each integer
version between them calling crate::Block::migrate once per
step. Authors write single-version-step migrators only; the
framework chains them.
§Wire-format version
The JSON envelope of a block entry stores version: u32 next to
type / id / value (explicit per-item versions beat
implicit ones). Missing
version is treated as 1 (the initial baseline).
Functions§
- apply_
migrations - Apply every step between
storedandblock.version()in order. Each step gets the previous step’s output. Already-current values (or future values stored by a newer process) short-circuit. - read_
stored_ version - Read the stored version off a
{type, id, value, version?}envelope. Missing / non-integer falls back to1so legacy streams that pre-date version-stamping just sail through unchanged (theirmigrate(1, …)for blocks at v1 is a no-op).