Ionic update local database without losing data - sqlite

It's probably a simple and common thing but I just can't find any help to do this in Ionic 5 app.
I have an app with local SQLite db. During the development when I update the table in the local db, I need to delete app/clean storage on the device for the update to be available. Is there a way to apply new changes on the existing db without losing data (without creating the whole db)?
same once app is released, with new updates, how do I make sure that new db changes are applied without re-creating the database?
A simple way I can think of is to put new changes in dbService constructor and check every time and apply change if need to. But this doesn't feel right to me.
Thanks

Related

Corona SDK - SQLLite Local Database and Updating

I was just looking for some guidance with my app design. I'm going to have a local sqllite database pre populated with about 1000 records.
These records will need to be read frequently within the app to update the UI.
The records will need to be updated from within the app.
Is a local mysql database the best way to do this or should I be storing all this info in a massive lua table? The database has 2 tables one with 2 columns and one with 10 columns.
I don't want the data to be accessible from outside the app as some of the data is going to be paid for content.
How would I go about releasing updates in the future? If I upgrade my app to version 2 and add new records to the database... how would I go about keeping the users existing data in the database and just adding the updated stuff?
Hope someone can point me in the right direction!
Many Thanks,
Krivvenz.
I think this is fairly simple question. If you need to use data after closing and opening the app you will need sqlite. If the data is created and lost after the app usage, then a table will do. However, the sqlite has also the advantage of querying, deleting and so many other functions without loops etc that you may need to do in tables manually.
You can also append further data during app update. The Sqlite file you create is saved to document directory. That is not deleted if you only update. Simply write a code in your update that reads the existing database and appends the new data. Or create a new file for sqlite and use the old one as backup.

Sq Lite Database Table upgrade

I am creating an app it takes data from the server and storing it in SQLite database but each time I run the app the data gets append in the database. I tried onUpgrade() method to drop table and create a new one, but its not working because db_version is the same. But if I change the version manually then its working... but I want solution so that my version changes each time automatically when I run the app....
OR if there is an another alternative please share it....
You are probably didn't understand what is database Upgrade. In two words you upgrade the version of your database when your DB model changed, not the data!
To clear your database for testing purposes use sqlite DROP TABLE or physically delete the file!
If you upgrade the version of the database each time your app starts - you will lose all the database data each time your app starts, so why do you need the database ?

How to perform specific operations during installating or updating a TideSDK app?

I went thru the docs but couldn't find how can I perform specific operations when app is being installed or when app is being updated.
What I want to do is, create table when app is being installed and if in future, db schema changes, I want to perform those operations when app is being updated.
According to me .. the best place to do these changes are in the code. so whenever the application starts up first time after getting updated.. you do all the db schema changes.
This makes sure that your application is fully updated before you touch any database and secondly u do not have to write any special logic separately while installing / updating the application.

Flash Builder 4.5 (Mobile) - Rolling out Database Updates

This is my first question on here so please be kind lol.
I am working on a mobile application with Flash Builder 4.5.
It uses a custom sql-lite database (tables are created on program load if they don't exist) to store the data. The data gets inserted by a sync process which connects to a web service.
I'm looking to ensure that changes to the database tables won't break the program.
For example I need to add a new field to an existing database table. I already know the SQL command (ALTER TABLE) for this but I'm not sure how to tie this to the update of the program i.e. when upgrading the program to 0.1 it should add the new field. But obviously I don't want it to try and add the field more than once.
Is there any way of knowing inside the program when it has been updated by the android/ios stores? Or any suggestions on how to handle these database changes?
The following answer has helped point me in the right direction:
database updates answer

Qt Sqlite user access

I'm working with sqlite and qt. I understand that sqlite doesn't have native user access control and am fine with that, and have a plan for controlling access using my application - set up some user groups in a db and authenticate on the app side.
What I would like to know is if there is an easy way to stop my views on QSqlRelationalTableModel data from updating the database (i.e make the database readonly).
I am currently using an editstrategy of OnFieldChange, if I change it to OnManualSubmit for example (without implementing a submit call), will that prevent updates to the dB?
Is there a cleverer way of doing this? Like making the view readonly?
If you create views, then they will be read-only since sqlite doesn't support updating views:
http://www.sqlite.org/lang_createview.html
EDIT
Following-up on your comment, is the QSQLITE_OPEN_READONLY connection setting what you are looking for?
http://doc.trolltech.com/4.6/qsqldatabase.html#setConnectOptions

Resources