Re:Ask HN: What are some examples of good database schema de...
by janci on Friday February 14, 2020 @05:21PM
(#22330977)
How do you solve event schema changes? I mean event has some data attached to it. The schema of this data may need to change in time. How to replay older events that do not match current schema? Do you keep all versions of event reactors to be able to replay old events?
[ Parent
| on HN ]
Re:Ask HN: What are some examples of good database schema de...
by fsajkdnjk on Friday February 14, 2020 @07:11PM
(#22331793)
the stored events are called event but they are actually envelopes. the true changes("event"), or payload of the envelope, is stored as serialized field. the envelope holds metadata like dates, domain, aggregate type and id, event name, correlation, causation, user/account, event schema version(this is what you are asking about) and so on. i am using protocol buffers so they are backwards compatible and event schema can evolve in time. but you can use any type of format as long as you keep the schema version within the envelope and only add new fields to the objects.
then, when you are parsing the events(hydrating or replaying) you just check the schema version in the envelope and handle the changes/payload accordingly.
it's actually very trivial once you put it all together.