Flash Builder 4.5 (Mobile) - Rolling out Database Updates - sqlite

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

Related

Ionic update local database without losing data

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

What's the best way to archive records in SQLite using EF Core to a new file

I have a .NET 6 application that writes logs out to a SQLite file each time a cycle is completed. I'm using EF Core.
The application sits on a Raspberry Pi with limited resource, so I want to keep the live database small as when it gets large the system slows down. So I want to archive the logs to only keep the last 50 or so logs in the live database.
I am hoping to create a method that will will create a new SQLite database file and then copy the last oldest record over when a new log is created. I'd also want to limit how big the archive file is, maybe split out to create a new one once it reaches a certain size on disk.
I've had a look around and can't find any best practices anything documented. Could someone give me a steer to the best way to achieve this or similar.
I solved my issue by putting EFCore aside and instead using the sqlite-net-pcl nuget package from SQLite-net.
This allowed me to separate the creation of my archive and also apply additional commands not supported in EFCore like vacuum.
I still use EFCore and Linq to query the records to create my archive with and then again to remove those records once the archive is created.

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.

How to persist SQLite database on Icenium?

I try to build a database on Icenium with SQLite and the db does not persist - why? I think the structure of the database is not built on a physical level. Someone you ever had this problem?
I was able to use SQLite with Icenium on my project successfully. As I see, there is also an example that you can look up:
https://github.com/Icenium/sample-sqlite.git
You might also want to take a look at this post: Creating a Database from a SQL Dump, for using prepopulated SQLite database.
From my experience with Telerik AppBuilder (formerly called Icenium), each time you Run the project in a simulator, the simulator starts from scratch and it keeps no record of what happened in previous runs.
The solution I would use to 'persist' the database on a session basis and test your code is as below.
You must keep the simulator open (so don't close it) to keep database intact
and just press Reload button in simulator window to see how an existing database
would run on a real device every time the app is re-started on a real device,
because within a single Run of the simulator it remembers everything.
Even if you want to make changes to your code or html, leave the simulator open and make your code changes (and Save), and then click on Refresh button in simulator window to bring in your recent code changes without losing the database and its data. If you follow this approach you can easily test how a database would behave on real device where a database is naturally persisted.
So think, in terms of 'simulator session' when developing hybrid apps using Telerik AppBuilder.

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