News for hackers. Stuff that matters.
Re:Event Sourcing (2005) by TobiasA on Thursday August 12, 2021 @03:32AM (#28153181)
How do people handle versioning events, like adding/removing/changing properties? It seems like your application would always need to be aware of all previous event versions to be able to replay all events.
Re:Event Sourcing (2005) by vgel on Thursday August 12, 2021 @03:40AM (#28153242)
Where I work (meetdandy.com, digital dental lab), we do a combination of:

For small changes like adding a field, we make the property on the underlying event optional, but require it in the event dispatch function. That allows old events to be missing the field, but type-checking still requires it in the codebase going forward. It does require a special case to handle the missing field, however.

For larger changes to events, we do migrations. We store events in Postgres, so we just use TypeORM migrations. I haven’t had to do one of these myself, but I’ve heard secondhand that it’s not too bad. We don’t have very many of these, regardless.