What to do if I updated the event class but forgot to upgrade revision number

I have this UserCreatedEvent class with revision 1.0

@Revision("1.0")
data class UserCreatedEvent(
   val userId: UUID,
   val firstname: String,
   val lastname: String
)

then later I updated the event by removing lastname field so it becomes like this

@Revision("1.0")
data class UserCreatedEvent(
   val userId: UUID,
   val firstname: String,
   // val lastname: String removed
)

but I forgot to change the revision number from 1.0 to 2.0 so it still remains 1.0. now my event store contains UserCreatedEvent with the same revision but different schema. Application still works just fine so I thought it was fine. but when I tried to re-run projection now it gives an error that there’s no lastname field in the UserCreatedEvent. I tried upcasting from revision 1.0 to 1.0 but it’s not working either. what should I do to solve the problem?

Hi Werapon, if you are using Jackson, it’s likely easiest to ignore the unknown properties. If using XStream you can do a similar thing, using ignoreUnknownElements.

1 Like

It works like a charm (using XStream). Thanks a lot :slightly_smiling_face:

1 Like