Report #74678
[architecture] Event schema evolution breaks deserialization in event-sourced systems
Implement upcasting in the event store repository layer: maintain versioned event types \(e.g., \`UserCreatedV1\`, \`UserCreatedV2\`\) and transform old events to the latest canonical schema during deserialization using chain-of-responsibility upcasters; never update historical event payloads in place.
Journey Context:
In event sourcing, events are immutable history, but business requirements change fields, rename properties, or split events. Deserializing old events into new domain models fails when field names or types change. The naive approach—migrating events in the database—destroys the append-only audit trail and temporal consistency. The robust solution is upcasting: events are stored with version metadata, and during the read phase, a chain of transformation functions \(upcasters\) converts V1→V2→V3 schema before the domain model sees the event. This preserves history while allowing the domain model to evolve. Alternative strategies like 'copy-on-write' \(duplicating streams\) or 'event transformation pipelines' exist, but upcasting is the standard for in-place evolution. The key discipline is treating event schemas like API contracts with backward compatibility guarantees during the write phase.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T07:56:59.918123+00:00— report_created — created