hive
hive copied to clipboard
I screwed up, is there anything I can do?
Hi,
I shipped an update of my app with changes to my Hive objects that are not compatible with my users old local data (e.G. changed data type, changed data structure etc..). Some users havent updated in months and Im not sure what old data they have. Now my users getting app crashes because their old data conflicts with the new data objects of the app update. I have to tell affected users to delete their app cache/ app data or the app is bricked, which is an awful experience.
Is there a general approach how can make sure the old data is not used anymore, like increasing data base version or a onMigrate: function? I could not find anything like that in the docs.
Edit:
To make myself more clear Im getting
HiveError: Box not found. Did you forget to call Hive.openBox()
in crashlytics from users on release side but I cannot reproduce the errors.
Thanks a lot!
Sorry to hear. When I faced a similar thing,I implemented a 'clean up' job that runs once on app update. Run it after initializing Hive, and make sure old data is removed or migrated: Hive.deleteFromDisk() should do the trick on the boxes that need cleaning
You can push a new update that does the migration.
Hey, thanks for the input. I ended up changing the names of all my boxes, so the old data will not be requested by the old boxes. Kind of hacky but I think it worked. Just out of curiousity: Are there plans to bring back something like a onMigrate function, and the versioning of boxes?
I don't think there are plans for that.
But how I currently do it.
At initialization I check if the old box exists and do the migration at startup. Then I delete the old box after migrating. Subsequently that piece of code won't be run anymore since the old box is gone from that device
@danielRi Last changes to the repo were made 2 years ago – Hive is not in active development, developer went on to work on isar as far as I know. So no updates are coming, maybe some critical bugfixes and that's it.