Hi all ! Could anyone suggest please, if exist way to listen installing new build and do alter table in SQLite if needable ?
You could make a const DATA_VERSION and save that in the DB and compare it every start of the app:
pseudocode:
const DATA_VERSION:number = 1; //Increment this number whit each version that you alter your db structure
function onStart() {
if(DATA_VERSION > /*version number that is stored in the db*/ ){
migrate(/*version number that is stored in the db*/).then( _ => {
/*set the version number that is stored in the db to DATA_VERSION*/
/* start the app like normal */
});
} else {/* start the app like normal */}
}
function migrate (oldversion:number):Promise<any> {
//Migrate the data, oldversion tells you from which version.
}
As alternative for const DATA_VERSION you could use the build number, but you won’t change your db structure every update, right?
PS: If you want to migrate from an version that is already in production you could also check is const DATA_VERSION is set.
And DATA_VERSION is just a random name, you could use every name you choose.
1 Like
user5555, thanks a lot.
Hi ,
Is there any event for update app from test flight ? i need to change the database schema while update the app
Thanks,
@subashravicse
There is no such event, how should it work anyway? Try the solution from above and if it doesn’t works for you tell us more about your special needs.