Is the Storage plugin to Preferences plugin migrate() call essential?

I’ve just updated all the way up from Capactor 2 to 7 - that was fun :sweat_smile:

I followed the docs for Preferences.migrate() to migrate the old Storage service data but noticed that the CapacitorStorage.xml doesn’t seem any different between the two. So I just tried an experiment (on Android only) updating my old app (cap v2) to my new app (cap v7) without calling migrate() and it still read the old CapacitorStorage.xml without any noticeable issues. I’m only storing a single key with the value being a JSON string of more key/value pairs. I’m not likely to risk not using it but I am intrigued. What does migrate actually do under the hood?

The migrate command was implemented because iOS and web used a special prefix on the data, on Android the prefix didn’t exist so you should see no difference.
If you target iOS and web you should call migrate, if not, there is no need.

2 Likes

Thank you for the reply, and the simple explanation. I am targeting iOS and Android, just hadn’t got as far as comparing iOS. I’ll keep using migrate().