Reputation: 697
Let's say I have an existing aggregate CustomAggregate
and an event CustomEvent
which is handled by the aggregate.
After some time when the event store already contains some events for this aggregate, I need to rename the aggregate and the event to NewCustomAggregate
and NewCustomEvent
. I update the revision of the renamed event and create a corresponding upcaster which is handling the event renaming.
But the type
in the table which serves as an event store still refers to CustomAggregate
. Hence, when I'm trying to get all events for the new aggregate type like this
eventStore.readEvents("NewCustomAggregate", id);
I'm (obviously) getting an exception saying that there are no events for this aggregate type.
Is there a way to not only consider the renamed/changed events in the upcaster, but also take into consideration that for certain event revisions the event store should treat the NewCustomAggregate
type as CustomAggregate
?
The Axon version I use is 2.4.6.
Upvotes: 0
Views: 862
Reputation: 2890
In Axon 2, you cannot upcast any information that's not in the payload of the event itself. Instead, you will have to change the aggregate type directly in the database.
A little backgroun: this column is used by Axon 2 to retrieve the events for a specific Aggregate (together with the aggregate identifier). If this were updated using an upcaster, the database wouldn't be able to match the type against any of the events. So basically, changing the value in the table is your best option.
Upvotes: 3