I’ve rewritten an Ionic/Cordova app with Capacitor. The Cordova version used Ionic Storage to keep track of user progress. This data is all local. Now with Capacitor, I’m having trouble accessing that storage with capacitor-community sqlite (GitHub - capacitor-community/sqlite: Community plugin for native & electron SQLite databases). I’m wondering if there’s a way I can access the same database or migrate to a new one while keeping all the data. I’ve never worked with databases before, so I’m not sure what things are required to get the capacitor sqlite database to use the Cordova one.
I thought this post could help, so I installed LocalForage, but all my queries are empty.
Is there anyway that I can migrate Ionic Storage to Capacitor?
Yeah, I’m using Ionic Storage with SQLite and I want to just keep the database the same, but access it with a Capacitor plugin instead (if that’s possible). About configuration, is there a default one? I didn’t write the Cordova version and I’m not seeing any configuration for it anywhere. The service that uses it just imports it, injects it in the constructor, and then uses it.
About the LocalForage, the link I shared mentioned that Ionic Storage uses LocalForage under the hood, so that’s why I tried it. I honestly didn’t verify that and don’t know how to. This is my first project using a database, so I’m pretty clueless.
I think you need to do a copy of data between Cordova and Capacitor instead of trying to move the underlying wiring from one to the other. The configuration of Ionic Storage and sqlite is in the docs (the API - Angular example):
Either way, you are likely to have dual existence of Cordova and Capacitor in the app for a while, until you are sure all data of all apps @ users are migrated. And then you can get rid of the Cordova thing.
The biggest test you need to do now is to have Capacitor and Cordova storage existing in the same app, and then copy data back and forth.