When aggregates come back from the dead


Using UUIDs in some cases introduces a mismatch with the business language.
Some object have serial numbers or another form of identifier that has business significance and no stakeholder seems to care about the surrogate application id when they talk with developers.

So I recently coded an new aggregate using its natural identifier as the proper aggregate id. And what a joy it was: cleaner, safer and easier to implement.

But there is a downside, it seems. In some circumstances these object are deleted and then recreated. Be it for testing, human errors or just fate.
However the second time around, this results in the aggregate going back to version 1 and failing to save, because the event with sequence number 1 is already present.

The use case is legit and for all intents and purposes the new object really is the old one come back to life, rightfully owning anything that still is attached to that id.

Is anyone dealing with this in any way?


Delete is just a command that sets a status attribute in the AR, so does recreate.

Not sure what you mean by the AR failing to save second time around.