Open let4be opened 9 years ago
another use case: let's suppose(there was such situation in the past) there was a tremendous bug in "0.4.1" and all emails user has sent - cannot be read by recipients, but there are some internal data structures that would help to resend those emails thus fixing this issue
we could make migration script that states - run me when we upgrade to anything >= 0.4.1 and I will fix the shit
one side thing: as we store most of our data in encrypted format such stuff can be performed only client-side.
There are situations when we want to upgrade format of some internal data structures inside
web
, currently it's handled in a hacky wayI suggest to implement so called migration scripts that will be distributed as a separate angular.js module and loaded dynamically if there is such need.
step-by-step how it would work:
migration: ["0.4.5"]
states that update to 0.4.5 requires run of the appropriate migration scriptuser.settings={dataVersion: "0.4.4"}
states that current internal data structures are compatible with all versions including 0.4.4 but are not compatible with anything further(i.e. "0.4.5" has introduces breaking changes)user.settings
andmanifest.migration
array if it find that in order to use current version we need to run a migration script(or a sequence of them) it downloads angular.js module with migration scripts and run all required scripts if everything went smoothly it updatesuser.settings.dataVersion
to the current version and continues application loadingThis would allow to keep code clean and tidy without ugly hacks to support multiple formats, once data structures have been updated using migration script we no longer need use hacky code to support weird and conflicting data formats across different versions.
For example recently I needed to update contacts structure as we removed hidden contacts concept and replaced them with regular contacts that user can delete/name/edit. Here it would be extremely useful i.e. new application can't use old format but old contacts are stored using old format so I had to modify code to support both
I find this more suitable approach instead of version each data structure separately - no need to support a ton of old outdated formats
cc @andreis @pzduniak