From d413c4f4c117078d8b5bfaa43ab8a1c980f1f72a Mon Sep 17 00:00:00 2001 From: ashilkn Date: Mon, 27 May 2024 12:57:25 +0530 Subject: [PATCH] [mob][photos] Add try catch + logs for debugging in FaceMLDataDB --- mobile/lib/face/db.dart | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/mobile/lib/face/db.dart b/mobile/lib/face/db.dart index c1b96767e..b00d56650 100644 --- a/mobile/lib/face/db.dart +++ b/mobile/lib/face/db.dart @@ -59,7 +59,13 @@ class FaceMLDataDB { _logger.info("Opening sqlite_async access: DB path " + databaseDirectory); final asyncDBConnection = SqliteDatabase(path: databaseDirectory, maxReaders: 2); + final stopwatch = Stopwatch()..start(); + _logger.info("FaceMLDataDB: Starting migration"); await _migrate(asyncDBConnection); + _logger.info( + "FaceMLDataDB Migration took ${stopwatch.elapsedMilliseconds} ms", + ); + stopwatch.stop(); return asyncDBConnection; } @@ -75,7 +81,12 @@ class FaceMLDataDB { _logger.info("Migrating database from $currentVersion to $toVersion"); await database.writeTransaction((tx) async { for (int i = currentVersion + 1; i <= toVersion; i++) { - await tx.execute(_migrationScripts[i - 1]); + try { + await tx.execute(_migrationScripts[i - 1]); + } catch (e) { + _logger.severe("Error running migration script index ${i - 1}", e); + rethrow; + } } await tx.execute('PRAGMA user_version = $toVersion'); });