migratingAdapter
migratingAdapter<
E>(chain,opts?):EventAdapter<E,unknown>
Defined in: src/persistence/migration/migratingAdapter.ts:31
Build an EventAdapter from a MigrationChain — convenience for the common case where one chain handles both directions (upcast on read, optional downcast on write).
writeVersion (defaults to the chain’s currentVersion) is the
version actually written to the journal. Set it lower than
currentVersion during a rolling deployment so v2 nodes keep
emitting v1 events for as long as v1 readers are still in the
cluster (#7). When writeVersion < currentVersion, the chain
must have downcasters covering every step on the path
currentVersion → writeVersion — otherwise toJournal throws.
const chain = MigrationChain.for
// Phase 1 of rollout — write v1 still, read both: const phase1 = migratingAdapter(chain, { writeVersion: 1 });
// Phase 2 once every reader is on the new code — flip: const phase2 = migratingAdapter(chain); // writeVersion = currentVersion = 2
Type Parameters
Section titled “Type Parameters”E
Parameters
Section titled “Parameters”writeVersion?
Section titled “writeVersion?”number
Returns
Section titled “Returns”EventAdapter<E, unknown>