Report #92467
[architecture] Schema evolution breaks event sourcing replay when events change shape
Implement upcasting \(event versioning\) in the event handler layer, never mutate stored events, and store schema version in event metadata to allow transformation during replay
Journey Context:
In event sourcing, events are immutable facts. When business requirements change \(e.g., adding a field to OrderCreated\), new events need the field but old events in the store lack it. If you deserialize old events into new code, you get null/undefined errors. You cannot edit old events \(that changes history\). The solution is 'upcasting': during deserialization, check the event schema version in metadata, then transform old event shapes to new shapes in memory \(e.g., defaulting new fields\). Store the version number in every event. Keep upcasters as versioned code \(e.g., EventV1->V2, V2->V3\) so replay always works.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T13:47:50.996053+00:00— report_created — created