Resetting Axon events across one aggregate

During the development stage of an aggregate with a PostgreSQL event store, it has been useful to remove all events in order to start out clean for iterative changes. When there was only one aggregate, I could simply drop all tables to reset the data. Now that the first aggregate is finalized, the data is now permanently in the event store. However, I’d like to take the same approach with a second aggregate, but as you can imagine, I can’t simply drop the tables now. So, is there a method I could use to specifically clear out all instances of one aggregate from the event store in the SQL while preserving the history of the others?

1 Like

Hi,

Not sure I would recommend to fiddle with the underlying event store.

That said: If you know your aggregate identifier, you could simply delete all entries from domain_event_entry with the corresponding aggregate_identifier field. I am not an Axon developer, but I would assume that Axon can handle gaps in the event store, so nothing should break when you do that. Note that you still have to remove data from other projections etc. manually.

May I ask why you would want to delete entries in the event store? From a plain CQRS perspective the event store in Axon should be append only. If the reason is GDPR, you might want to consider another approach, e.g. moving sensitive data to another table which you can control.

Best regards

Nils

Hey @cwireman,

You can achieve this by introducing a soft delete mechanism for events related to the second aggregate. Add a flag or column in the event table to mark events belonging to the second aggregate as deleted. Then, adjust your queries to ignore these deleted events while preserving the history of other aggregates.

Visit to this: https://stackoverflow.com/questions/58520890/axon-recreating-aggregate-state-not-clear-msbi

Thanks,
Steve