I'm new to application programming. I'm developing an application on ionic 2
with angular 2
. There was a doubt, I have a provider
and in it I do the whole part of the database using SQLite
, only the need arose to add a field to the table, so I added the field, but had a problem I had to uninstall the application for that update to work, then in that case I lost all the data, I almost cleared the database for the update to be installed.
Would you have any way to do this update without having to reset the database by uninstalling the application?
Follow my provider
.
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';
import { SQLite, SQLiteObject } from '@ionic-native/sqlite';
@Injectable()
export class RomaneioBdSql {
storage: any;
public romaneios: Array<Object>;
constructor(public http: Http, public sqlite: SQLite) {
this.sqlite.create({
name: 'infoged.db',
location: 'default'
}).then((db: SQLiteObject) => {
db.executeSql('create table IF NOT EXISTS tb_romaneio(id_romaneio INTEGER PRIMARY KEY AUTOINCREMENT,' +
'romaneio_name VARCHAR(32),' +
'romaneio_motorista VARCHAR(52) default NULL, ' +
'romaneio_nota VARCHAR(19),' +
'romaneio_serie VARCHAR(9),' +
'romaneio_sincronizada integer(1) default 0' +
')', {})
.then(ed => /*alert(JSON.stringify(ed))*/ed)
.catch(e => alert(JSON.stringify(e)));
}).catch(e => alert(JSON.stringify(e)));
}