Corrige esquema DB: agrega es_recurrente en CREATE TABLE y migración a v3
This commit is contained in:
@@ -19,7 +19,7 @@ class DatabaseHelper {
|
|||||||
Future<Database> _initDB(String filePath) async {
|
Future<Database> _initDB(String filePath) async {
|
||||||
final dbPath = await getDatabasesPath();
|
final dbPath = await getDatabasesPath();
|
||||||
final path = join(dbPath, filePath);
|
final path = join(dbPath, filePath);
|
||||||
return await openDatabase(path, version: 2, onCreate: _createDB, onUpgrade: _upgradeDB, onConfigure: _onConfigure);
|
return await openDatabase(path, version: 3, onCreate: _createDB, onUpgrade: _upgradeDB, onConfigure: _onConfigure);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future _onConfigure(Database db) async {
|
Future _onConfigure(Database db) async {
|
||||||
@@ -27,9 +27,11 @@ class DatabaseHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future _upgradeDB(Database db, int oldVersion, int newVersion) async {
|
Future _upgradeDB(Database db, int oldVersion, int newVersion) async {
|
||||||
if (oldVersion < 2) {
|
if (oldVersion < 3) {
|
||||||
await db.execute(
|
try {
|
||||||
"ALTER TABLE servicios ADD COLUMN es_recurrente INTEGER NOT NULL DEFAULT 0");
|
await db.execute(
|
||||||
|
"ALTER TABLE servicios ADD COLUMN es_recurrente INTEGER NOT NULL DEFAULT 0");
|
||||||
|
} catch (_) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +43,8 @@ class DatabaseHelper {
|
|||||||
icono TEXT NOT NULL,
|
icono TEXT NOT NULL,
|
||||||
color INTEGER NOT NULL,
|
color INTEGER NOT NULL,
|
||||||
dia_vencimiento INTEGER NOT NULL,
|
dia_vencimiento INTEGER NOT NULL,
|
||||||
fecha_creacion TEXT NOT NULL
|
fecha_creacion TEXT NOT NULL,
|
||||||
|
es_recurrente INTEGER NOT NULL DEFAULT 0
|
||||||
)
|
)
|
||||||
''');
|
''');
|
||||||
await db.execute('''
|
await db.execute('''
|
||||||
|
|||||||
Reference in New Issue
Block a user