Question: Renaming events and identities #862
-
We're currently using Eventflow in production, only just released MVP and it's become necessary to rename an aggregate and some of its events. Is there a recommended method for renaming events and identities? Currently using sql+efcore for storage. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Since you are essentially changing events, the preferred method is to use event upgraders and map the old events to the new ones. https://docs.geteventflow.net/EventUpgrade.html Please note that the old events will still be present in the event stream, but your aggregates won’t need to handle them as they are mapped. If you ever delete aggregates, you could check if all of the old events are gone at some point and then delete the events and the upgraders . |
Beta Was this translation helpful? Give feedback.
-
What about the name of the aggregate and the prefix on the id. Should I create a brand new aggregate with a new identity class and migrate the events to that? |
Beta Was this translation helpful? Give feedback.
-
Renaming things in an event sourcing system is generally not something you want to do unless you have to. In this case, renaming events is supported as @rasmus say. But renaming the aggregate is not supported the same way. You could rename the class, with AggregateNameAttribute set to the old name. If that is not good enough, you can use the same mechanic to upgrade all events to new versions that operate on the new aggregate just as I think you already have figured out - it's not a simple thing to do, but certainly possible. Another way could be directly modify the events in the database, but I'd strongly advice against this unless you have a really good reason. |
Beta Was this translation helpful? Give feedback.
Renaming things in an event sourcing system is generally not something you want to do unless you have to. In this case, renaming events is supported as @rasmus say. But renaming the aggregate is not supported the same way. You could rename the class, with AggregateNameAttribute set to the old name. If that is not good enough, you can use the same mechanic to upgrade all events to new versions that operate on the new aggregate just as I think you already have figured out - it's not a simple thing to do, but certainly possible.
Another way could be directly modify the events in the database, but I'd strongly advice against this unless you have a really good reason.