Handling schema change (property type change) in javers #511
I have my java class which consists of Map<String, String>. I am using javers sql repository for storing my auditing data. I recently changed schema of my property to Map<String, List>. Now I am getting following exception on commits of the domain. I think Javers should internally handle any schema changes.
Current javers version - 2.8.2
The text was updated successfully, but these errors were encountered:
Just stumbled across this and sounds like a deal breaker for choosing JaVers :(. Changes to entities are done often (e.g. renaming, adding or removing attributes, changing type). These are currently handled nicely with Liquibase in my service. Would that mean, I have to write two updates now? One using Liquibase and a "custom" one for updating JaVers repository and somehow "patching" the JSON in there?
What JaVers operations are affected by such attribute changes? Only constructing a "real" Entity out of the snapshots/diffs or also just evaluating what has changed in the past (diffs)? Looking at the stacktrace above it seems that it also "simply" breaks suddenly on a simple save on the repository then, right?
So what are the recommendations of the JaVers team to handle such scenarios? I can't think of a generic mechanism that is able to perform e.g. all possible attribute type changes automagically :).
E.g. for my scenario it would be sufficient, that I can simply query for the diffs of an object over time. If a type doesn't match anymore (previous and actual), it would be fine for me to just let JaVers mark the attribute as "changed" and simply store the new type/value from now on. Without actually dying on a simple save operation. I something like this with custom hooks/listeners possible currently?
Hi @vguna, lot of questions ...
class name and property name changes are already covered by @typename and @PropertyName annotations. You don't need to update existing Snapshots. Snapshots are immutable.
What is not covered is changing property type, for example from string to int, and I think this issue is about it.
Yeah, sorry about that, but some questions are still unanswered for me ;). If these are already covered by the documentation, please give me a hint where to look.
So I understand that changes of names can be handled by the given annotations.
What happens if attributes are removed or added? Are these handled transparently for me?
Where are the places where my (JaVers related) code could break due to the type problem and what is your recommendation to handle such scenarios?
Are there already hooks/listeners that I could use to handle such situations?
Unfortunately I experience a similar issue with JaVers 3.10.2 after a schema change (was: reference to another Entity, now: String). Renaming attributes in Entities is not a solution; yet I got no clue what to do as migrating data would mean to lose the audit trail...