For renames and type changes, there is an UID-based approach to work with already deployed databases.
However during development, it may just be easier to wipe all data and model data.
API outline:
MyObjectBox.builder().version(7).nukeDataBeforeVersion(7)
Thus, ObjectBox would track the current version of the data model, and just discard everything for earlier versions.
Alternative API: annotations, but where to apply them? Also the builder seems appropriate because that's where the initialization happens.
Looking into the future, this approach should also work nicely with custom migration callbacks. E.g.
MyObjectBox.builder().version(10).nukeDataBeforeVersion(7).migrate(new MyMigration())
Here, versions 1 to 6 just would be nuked, and version 10 would be applied. For versions 7 to 9, the custom migration would be triggered.
Feedback on this approach welcome!
@greenrobot
At which version it can be implemented, do you have any plans regarding this feature?
Can you suggest any way to implement custom migration for now?
Any news? Really need this feature to simplifies data model changes.
Most helpful comment
@greenrobot
At which version it can be implemented, do you have any plans regarding this feature?
Can you suggest any way to implement custom migration for now?