You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been using your starter template (It's great, thanks). I noticed when deployed to a device (Android) the "preload" database transactions specified do not execute unless it is in the browser.
This appears to be because we only execute the pre-defined transactions if if (window.sqlitePlugin === undefined) {
In the self.db method we already handle getting a database based on it being in app (and window.sqlitePlugin` being available or running in the browser. I don't think there is a need to check that the plugin is undefined before executing the preloading statements, without it, it appears to work fine.
I changed your version of the SQL Lite service to get an instance of the database, create (if not exists) a version history table, and then migrate from the current version to the new version if it is behind, this enables me to deploy SQL Updates to future versions of the app instead of running into problems later.
Cheers
Lee
The text was updated successfully, but these errors were encountered:
Hi Lee,
Thanks for your comments! 💯
In the browser is required to execute the queries to preload the database, but in the mobile you can use the pre.db file (A pre-populated database that you can edit using DB Browser for SQLite)
I have an implementation about migrations, I need to include that in this template.
Let me check your example! 👍
You are indeed correct, I don't think that would be suitable for my specific application though as I foresee many migrations and the pre-populated Db wouldn't necessarily let me do this, or apply future ALTER TABLE / INSERT / UPDATE statements as the app progresses.
My initial thought on migrations was that I wanted a .NET Entity Framework type migration system but I decided it was too much effort.
Instead, I opted for a simple means of knowing the current version number and applying any missing updates upon the launch of the app. I found a solution by Alin Pandichi that met my requirements so I didn't have to write my own so credits to him.
I've forked the repo and committed this so you can see my approach. I've not used this in production yet but having tested in the browser and on multiple devices it seems to work great so far.
Hi,
I've been using your starter template (It's great, thanks). I noticed when deployed to a device (Android) the "preload" database transactions specified do not execute unless it is in the browser.
This appears to be because we only execute the pre-defined transactions if
if (window.sqlitePlugin === undefined) {
Line 75: https://github.com/jdnichollsc/Ionic-Starter-Template/blob/master/app/js/services/sqlite.js
In the
self.db
method we already handle getting a database based on it being in app (and window.sqlitePlugin` being available or running in the browser. I don't think there is a need to check that the plugin is undefined before executing the preloading statements, without it, it appears to work fine.I changed your version of the SQL Lite service to get an instance of the database, create (if not exists) a version history table, and then migrate from the current version to the new version if it is behind, this enables me to deploy SQL Updates to future versions of the app instead of running into problems later.
Cheers
Lee
The text was updated successfully, but these errors were encountered: