From 0efbf407d3531b18399b0cdac475df97da9b20a7 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Thu, 27 Feb 2025 14:11:52 +0530 Subject: [PATCH] [mob] table for collection_files and files --- mobile/lib/db/remote/db.dart | 1 + mobile/lib/db/remote/migration.dart | 44 +++++++++++++++++++++-------- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/mobile/lib/db/remote/db.dart b/mobile/lib/db/remote/db.dart index 314bb3b90b..1c80f3252b 100644 --- a/mobile/lib/db/remote/db.dart +++ b/mobile/lib/db/remote/db.dart @@ -88,6 +88,7 @@ class RemoteDB { ); } + Future deleteCollectionFilesDiff( List items, ) async { diff --git a/mobile/lib/db/remote/migration.dart b/mobile/lib/db/remote/migration.dart index 2c11052a47..84e8fd3d2d 100644 --- a/mobile/lib/db/remote/migration.dart +++ b/mobile/lib/db/remote/migration.dart @@ -9,6 +9,12 @@ const collectionColumns = const collectionFilesColumns = 'collection_id, file_id, enc_key, enc_key_nonce, created_at, updated_at, is_deleted'; + +const filesColumns = + 'id, owner_id, file_header, thumb_header, metadata, pri_medata, pub_medata, info'; +const trashedFilesColumns = + 'id, owner_id, file_header, thumb_header, metadata, pri_medata, pub_medata, info, trash_data'; + String collectionValuePlaceHolder = collectionColumns.split(',').map((_) => '?').join(','); @@ -35,19 +41,33 @@ class RemoteDBMigration { shared_mmd_ver INTEGER NOT NULL DEFAULT 0 ); ''', + ''' + CREATE TABLE collection_files ( + file_id INTEGER NOT NULL, + collection_id INTEGER NOT NULL, + PRIMARY KEY (file_id, collection_id) + enc_key BLOB NOT NULL, + enc_key_nonce BLOB NOT NULL, + is_deleted INTEGER NOT NULL + updated_at INTEGER NOT NULL, + created_at INTEGER NOT NULL DEFAULT 0, + ) + ''', + ''' + CREATE TABLE files ( + id INTEGER PRIMARY KEY, + owner_id INTEGER NOT NULL, + file_header BLOB NOT NULL, + thumb_header BLOB NOT NULL, + metadata TEXT NOT NULL', + pri_medata TEXT NOT NULL DEFAULT '{}', + pub_medata TEXT NOT NULL DEFAULT '{}', + info TEXT DEFAULT '{}', + trash_data TEXT, + FOREIGN KEY(id) REFERENCES collection_files(file_id) + ) + ''', ]; - // ''' - // CREATE TABLE collection_files ( - // file_id INTEGER NOT NULL, - // collection_id INTEGER NOT NULL, - // PRIMARY KEY (file_id, collection_id) - // enc_key TEXT NOT NULL, - // enc_key_nonce TEXT NOT NULL, - // is_deleted INTEGER NOT NULL - // updated_at INTEGER NOT NULL, - // created_at INTEGER NOT NULL DEFAULT 0, - // ) - // ''', static Future migrate( SqliteDatabase database,