From 8c4e75d26815919b677105974e0ec9c76fa8b2ae Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Mon, 5 Aug 2019 11:07:58 +0200 Subject: [PATCH] [Store] Fix db migration --- lib/src/Store.dart | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/src/Store.dart b/lib/src/Store.dart index 1637e3a..ea92a6c 100644 --- a/lib/src/Store.dart +++ b/lib/src/Store.dart @@ -55,7 +55,7 @@ class Store { _init() async { var databasePath = await getDatabasesPath(); String path = p.join(databasePath, "FluffyMatrix.db"); - _db = await openDatabase(path, version: 8, + _db = await openDatabase(path, version: 9, onCreate: (Database db, int version) async { await createTables(db); }, onUpgrade: (Database db, int oldVersion, int newVersion) async { @@ -63,7 +63,7 @@ class Store { print( "[Store] Migrate databse from version $oldVersion to $newVersion"); if (oldVersion != newVersion) { - await schemes.forEach((name, scheme) async { + await schemes.forEach((String name, String scheme) async { await db.execute("DROP TABLE IF EXISTS ?", [name]); }); db.rawUpdate("UPDATE Clients SET prev_batch='' WHERE client=?", @@ -97,7 +97,7 @@ class Store { } Future createTables(Database db) async { - await schemes.forEach((name, scheme) async { + await schemes.forEach((String name, String scheme) async { await db.execute(scheme); }); } @@ -129,8 +129,8 @@ class Store { Future clear() async { await _db .rawDelete("DELETE FROM Clients WHERE client=?", [client.clientName]); - await schemes.forEach((name, scheme) async { - if (name != "Clients") await db.rawDelete("DELETE FROM ?", [name]); + await schemes.forEach((String name, String scheme) async { + if (name != "Clients") await db.rawDelete("DELETE FROM $name", [name]); }); return; }