From 5fa2b34f350d8b914f337626ed22ba82e1bde9a3 Mon Sep 17 00:00:00 2001 From: Prateek Sunal Date: Fri, 12 Apr 2024 22:47:43 +0530 Subject: [PATCH] fix: update database logic --- mobile/lib/db/upload_locks_db.dart | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mobile/lib/db/upload_locks_db.dart b/mobile/lib/db/upload_locks_db.dart index 9995caefe..dcf9b5c3e 100644 --- a/mobile/lib/db/upload_locks_db.dart +++ b/mobile/lib/db/upload_locks_db.dart @@ -103,7 +103,7 @@ class UploadLocksDB { CREATE TABLE ${_trackUploadTable.table} ( ${_trackUploadTable.columnID} INTEGER PRIMARY KEY, ${_trackUploadTable.columnLocalID} TEXT NOT NULL, - ${_trackUploadTable.columnFileHash} TEXT NOT NULL UNIQUE, + ${_trackUploadTable.columnFileHash} TEXT NOT NULL, ${_trackUploadTable.columnEncryptedFilePath} TEXT NOT NULL, ${_trackUploadTable.columnEncryptedFileSize} INTEGER NOT NULL, ${_trackUploadTable.columnFileKey} TEXT NOT NULL, @@ -117,10 +117,11 @@ class UploadLocksDB { await db.execute( ''' CREATE TABLE ${_partsTable.table} ( - ${_partsTable.columnObjectKey} TEXT PRIMARY KEY NOT NULL REFERENCES ${_trackUploadTable.table}(${_trackUploadTable.columnObjectKey}) ON DELETE CASCADE, + ${_partsTable.columnObjectKey} TEXT NOT NULL REFERENCES ${_trackUploadTable.table}(${_trackUploadTable.columnObjectKey}) ON DELETE CASCADE, ${_partsTable.columnPartNumber} INTEGER NOT NULL, ${_partsTable.columnPartUrl} TEXT NOT NULL, - ${_partsTable.columnPartStatus} TEXT NOT NULL + ${_partsTable.columnPartStatus} TEXT NOT NULL, + PRIMARY KEY (${_partsTable.columnObjectKey}, ${_partsTable.columnPartNumber}) ) ''', ); @@ -193,6 +194,7 @@ class UploadLocksDB { _trackUploadTable.table, where: '${_trackUploadTable.columnLocalID} = ? AND ${_trackUploadTable.columnFileHash} = ?', + whereArgs: [localId, hash], ); return rows.isNotEmpty;