From 2ddaf6a611ba480cccfb79f06672dc7d00bf95f8 Mon Sep 17 00:00:00 2001 From: shenlong <139912620+shenlong-tanwen@users.noreply.github.com> Date: Tue, 12 May 2026 23:43:24 +0700 Subject: [PATCH] fix: indexes on remote_asset_entity (#28264) * fix: periodically execute pragma optimize * fix: indexes on remote_asset_entity * regen files --------- Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com> Co-authored-by: Alex --- .../drift_schemas/main/drift_schema_v25.json | 234 +++++++++--------- .../drift_schemas/main/drift_schema_v26.json | 234 +++++++++--------- .../entities/asset_face.entity.dart | 5 + .../entities/asset_face.entity.drift.dart | 4 + .../infrastructure/entities/exif.entity.dart | 4 + .../entities/exif.entity.drift.dart | 5 + .../entities/remote_asset.entity.dart | 13 +- .../entities/remote_asset.entity.drift.dart | 20 +- .../repositories/db.repository.dart | 6 + .../repositories/db.repository.drift.dart | 6 +- .../repositories/db.repository.steps.dart | 56 ++--- .../test/drift/main/generated/schema_v25.dart | 28 +-- .../test/drift/main/generated/schema_v26.dart | 28 +-- 13 files changed, 327 insertions(+), 316 deletions(-) diff --git a/mobile/drift_schemas/main/drift_schema_v25.json b/mobile/drift_schemas/main/drift_schema_v25.json index 95fa57d4d2..5a3f78aae7 100644 --- a/mobile/drift_schemas/main/drift_schema_v25.json +++ b/mobile/drift_schemas/main/drift_schema_v25.json @@ -1003,20 +1003,6 @@ 1 ], "type": "index", - "data": { - "on": 1, - "name": "idx_remote_asset_owner_checksum", - "sql": "CREATE INDEX IF NOT EXISTS idx_remote_asset_owner_checksum ON remote_asset_entity (owner_id, checksum)", - "unique": false, - "columns": [] - } - }, - { - "id": 12, - "references": [ - 1 - ], - "type": "index", "data": { "on": 1, "name": "UQ_remote_assets_owner_checksum", @@ -1026,7 +1012,7 @@ } }, { - "id": 13, + "id": 12, "references": [ 1 ], @@ -1040,7 +1026,7 @@ } }, { - "id": 14, + "id": 13, "references": [ 1 ], @@ -1054,7 +1040,7 @@ } }, { - "id": 15, + "id": 14, "references": [ 1 ], @@ -1067,36 +1053,22 @@ "columns": [] } }, + { + "id": 15, + "references": [ + 1 + ], + "type": "index", + "data": { + "on": 1, + "name": "idx_remote_asset_owner_visibility_deleted_created", + "sql": "CREATE INDEX IF NOT EXISTS idx_remote_asset_owner_visibility_deleted_created\nON remote_asset_entity (owner_id, visibility, deleted_at, created_at DESC)\n", + "unique": false, + "columns": [] + } + }, { "id": 16, - "references": [ - 1 - ], - "type": "index", - "data": { - "on": 1, - "name": "idx_remote_asset_local_date_time_day", - "sql": "CREATE INDEX IF NOT EXISTS idx_remote_asset_local_date_time_day ON remote_asset_entity (STRFTIME('%Y-%m-%d', local_date_time))", - "unique": false, - "columns": [] - } - }, - { - "id": 17, - "references": [ - 1 - ], - "type": "index", - "data": { - "on": 1, - "name": "idx_remote_asset_local_date_time_month", - "sql": "CREATE INDEX IF NOT EXISTS idx_remote_asset_local_date_time_month ON remote_asset_entity (STRFTIME('%Y-%m', local_date_time))", - "unique": false, - "columns": [] - } - }, - { - "id": 18, "references": [], "type": "table", "data": { @@ -1226,7 +1198,7 @@ } }, { - "id": 19, + "id": 17, "references": [ 0 ], @@ -1301,7 +1273,7 @@ } }, { - "id": 20, + "id": 18, "references": [ 0 ], @@ -1388,7 +1360,7 @@ } }, { - "id": 21, + "id": 19, "references": [ 1 ], @@ -1644,7 +1616,7 @@ } }, { - "id": 22, + "id": 20, "references": [ 1, 4 @@ -1718,7 +1690,7 @@ } }, { - "id": 23, + "id": 21, "references": [ 4, 0 @@ -1806,7 +1778,7 @@ } }, { - "id": 24, + "id": 22, "references": [ 1 ], @@ -1902,7 +1874,7 @@ } }, { - "id": 25, + "id": 23, "references": [ 0 ], @@ -2066,10 +2038,10 @@ } }, { - "id": 26, + "id": 24, "references": [ 1, - 25 + 23 ], "type": "table", "data": { @@ -2140,7 +2112,7 @@ } }, { - "id": 27, + "id": 25, "references": [ 0 ], @@ -2284,10 +2256,10 @@ } }, { - "id": 28, + "id": 26, "references": [ 1, - 27 + 25 ], "type": "table", "data": { @@ -2461,7 +2433,7 @@ } }, { - "id": 29, + "id": 27, "references": [], "type": "table", "data": { @@ -2509,7 +2481,7 @@ } }, { - "id": 30, + "id": 28, "references": [], "type": "table", "data": { @@ -2684,7 +2656,7 @@ } }, { - "id": 31, + "id": 29, "references": [ 1 ], @@ -2778,7 +2750,7 @@ } }, { - "id": 32, + "id": 30, "references": [], "type": "table", "data": { @@ -2826,13 +2798,13 @@ } }, { - "id": 33, + "id": 31, "references": [ - 20 + 18 ], "type": "index", "data": { - "on": 20, + "on": 18, "name": "idx_partner_shared_with_id", "sql": "CREATE INDEX IF NOT EXISTS idx_partner_shared_with_id ON partner_entity (shared_with_id)", "unique": false, @@ -2840,19 +2812,47 @@ } }, { - "id": 34, + "id": 32, "references": [ - 21 + 19 ], "type": "index", "data": { - "on": 21, + "on": 19, "name": "idx_lat_lng", "sql": "CREATE INDEX IF NOT EXISTS idx_lat_lng ON remote_exif_entity (latitude, longitude)", "unique": false, "columns": [] } }, + { + "id": 33, + "references": [ + 19 + ], + "type": "index", + "data": { + "on": 19, + "name": "idx_remote_exif_city", + "sql": "CREATE INDEX IF NOT EXISTS idx_remote_exif_city\nON remote_exif_entity (city) WHERE city IS NOT NULL\n", + "unique": false, + "columns": [] + } + }, + { + "id": 34, + "references": [ + 20 + ], + "type": "index", + "data": { + "on": 20, + "name": "idx_remote_album_asset_album_asset", + "sql": "CREATE INDEX IF NOT EXISTS idx_remote_album_asset_album_asset ON remote_album_asset_entity (album_id, asset_id)", + "unique": false, + "columns": [] + } + }, { "id": 35, "references": [ @@ -2861,20 +2861,6 @@ "type": "index", "data": { "on": 22, - "name": "idx_remote_album_asset_album_asset", - "sql": "CREATE INDEX IF NOT EXISTS idx_remote_album_asset_album_asset ON remote_album_asset_entity (album_id, asset_id)", - "unique": false, - "columns": [] - } - }, - { - "id": 36, - "references": [ - 24 - ], - "type": "index", - "data": { - "on": 24, "name": "idx_remote_asset_cloud_id", "sql": "CREATE INDEX IF NOT EXISTS idx_remote_asset_cloud_id ON remote_asset_cloud_id_entity (cloud_id)", "unique": false, @@ -2882,13 +2868,13 @@ } }, { - "id": 37, + "id": 36, "references": [ - 27 + 25 ], "type": "index", "data": { - "on": 27, + "on": 25, "name": "idx_person_owner_id", "sql": "CREATE INDEX IF NOT EXISTS idx_person_owner_id ON person_entity (owner_id)", "unique": false, @@ -2896,13 +2882,13 @@ } }, { - "id": 38, + "id": 37, "references": [ - 28 + 26 ], "type": "index", "data": { - "on": 28, + "on": 26, "name": "idx_asset_face_person_id", "sql": "CREATE INDEX IF NOT EXISTS idx_asset_face_person_id ON asset_face_entity (person_id)", "unique": false, @@ -2910,13 +2896,13 @@ } }, { - "id": 39, + "id": 38, "references": [ - 28 + 26 ], "type": "index", "data": { - "on": 28, + "on": 26, "name": "idx_asset_face_asset_id", "sql": "CREATE INDEX IF NOT EXISTS idx_asset_face_asset_id ON asset_face_entity (asset_id)", "unique": false, @@ -2924,13 +2910,27 @@ } }, { - "id": 40, + "id": 39, "references": [ - 30 + 26 ], "type": "index", "data": { - "on": 30, + "on": 26, + "name": "idx_asset_face_visible_person", + "sql": "CREATE INDEX IF NOT EXISTS idx_asset_face_visible_person\nON asset_face_entity (person_id, asset_id)\nWHERE is_visible = 1 AND deleted_at IS NULL\n", + "unique": false, + "columns": [] + } + }, + { + "id": 40, + "references": [ + 28 + ], + "type": "index", + "data": { + "on": 28, "name": "idx_trashed_local_asset_checksum", "sql": "CREATE INDEX IF NOT EXISTS idx_trashed_local_asset_checksum ON trashed_local_asset_entity (checksum)", "unique": false, @@ -2940,11 +2940,11 @@ { "id": 41, "references": [ - 30 + 28 ], "type": "index", "data": { - "on": 30, + "on": 28, "name": "idx_trashed_local_asset_album", "sql": "CREATE INDEX IF NOT EXISTS idx_trashed_local_asset_album ON trashed_local_asset_entity (album_id)", "unique": false, @@ -2954,11 +2954,11 @@ { "id": 42, "references": [ - 31 + 29 ], "type": "index", "data": { - "on": 31, + "on": 29, "name": "idx_asset_edit_asset_id", "sql": "CREATE INDEX IF NOT EXISTS idx_asset_edit_asset_id ON asset_edit_entity (asset_id)", "unique": false, @@ -3066,15 +3066,6 @@ } ] }, - { - "name": "idx_remote_asset_owner_checksum", - "sql": [ - { - "dialect": "sqlite", - "sql": "CREATE INDEX IF NOT EXISTS idx_remote_asset_owner_checksum ON remote_asset_entity (owner_id, checksum)" - } - ] - }, { "name": "UQ_remote_assets_owner_checksum", "sql": [ @@ -3112,20 +3103,11 @@ ] }, { - "name": "idx_remote_asset_local_date_time_day", + "name": "idx_remote_asset_owner_visibility_deleted_created", "sql": [ { "dialect": "sqlite", - "sql": "CREATE INDEX IF NOT EXISTS idx_remote_asset_local_date_time_day ON remote_asset_entity (STRFTIME('%Y-%m-%d', local_date_time))" - } - ] - }, - { - "name": "idx_remote_asset_local_date_time_month", - "sql": [ - { - "dialect": "sqlite", - "sql": "CREATE INDEX IF NOT EXISTS idx_remote_asset_local_date_time_month ON remote_asset_entity (STRFTIME('%Y-%m', local_date_time))" + "sql": "CREATE INDEX IF NOT EXISTS idx_remote_asset_owner_visibility_deleted_created ON remote_asset_entity (owner_id, visibility, deleted_at, created_at DESC)" } ] }, @@ -3282,6 +3264,15 @@ } ] }, + { + "name": "idx_remote_exif_city", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE INDEX IF NOT EXISTS idx_remote_exif_city ON remote_exif_entity (city) WHERE city IS NOT NULL" + } + ] + }, { "name": "idx_remote_album_asset_album_asset", "sql": [ @@ -3327,6 +3318,15 @@ } ] }, + { + "name": "idx_asset_face_visible_person", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE INDEX IF NOT EXISTS idx_asset_face_visible_person ON asset_face_entity (person_id, asset_id) WHERE is_visible = 1 AND deleted_at IS NULL" + } + ] + }, { "name": "idx_trashed_local_asset_checksum", "sql": [ diff --git a/mobile/drift_schemas/main/drift_schema_v26.json b/mobile/drift_schemas/main/drift_schema_v26.json index db90edc24b..b958bcca43 100644 --- a/mobile/drift_schemas/main/drift_schema_v26.json +++ b/mobile/drift_schemas/main/drift_schema_v26.json @@ -1013,20 +1013,6 @@ 1 ], "type": "index", - "data": { - "on": 1, - "name": "idx_remote_asset_owner_checksum", - "sql": "CREATE INDEX IF NOT EXISTS idx_remote_asset_owner_checksum ON remote_asset_entity (owner_id, checksum)", - "unique": false, - "columns": [] - } - }, - { - "id": 12, - "references": [ - 1 - ], - "type": "index", "data": { "on": 1, "name": "UQ_remote_assets_owner_checksum", @@ -1036,7 +1022,7 @@ } }, { - "id": 13, + "id": 12, "references": [ 1 ], @@ -1050,7 +1036,7 @@ } }, { - "id": 14, + "id": 13, "references": [ 1 ], @@ -1064,7 +1050,7 @@ } }, { - "id": 15, + "id": 14, "references": [ 1 ], @@ -1077,36 +1063,22 @@ "columns": [] } }, + { + "id": 15, + "references": [ + 1 + ], + "type": "index", + "data": { + "on": 1, + "name": "idx_remote_asset_owner_visibility_deleted_created", + "sql": "CREATE INDEX IF NOT EXISTS idx_remote_asset_owner_visibility_deleted_created\nON remote_asset_entity (owner_id, visibility, deleted_at, created_at DESC)\n", + "unique": false, + "columns": [] + } + }, { "id": 16, - "references": [ - 1 - ], - "type": "index", - "data": { - "on": 1, - "name": "idx_remote_asset_local_date_time_day", - "sql": "CREATE INDEX IF NOT EXISTS idx_remote_asset_local_date_time_day ON remote_asset_entity (STRFTIME('%Y-%m-%d', local_date_time))", - "unique": false, - "columns": [] - } - }, - { - "id": 17, - "references": [ - 1 - ], - "type": "index", - "data": { - "on": 1, - "name": "idx_remote_asset_local_date_time_month", - "sql": "CREATE INDEX IF NOT EXISTS idx_remote_asset_local_date_time_month ON remote_asset_entity (STRFTIME('%Y-%m', local_date_time))", - "unique": false, - "columns": [] - } - }, - { - "id": 18, "references": [], "type": "table", "data": { @@ -1236,7 +1208,7 @@ } }, { - "id": 19, + "id": 17, "references": [ 0 ], @@ -1311,7 +1283,7 @@ } }, { - "id": 20, + "id": 18, "references": [ 0 ], @@ -1398,7 +1370,7 @@ } }, { - "id": 21, + "id": 19, "references": [ 1 ], @@ -1654,7 +1626,7 @@ } }, { - "id": 22, + "id": 20, "references": [ 1, 4 @@ -1728,7 +1700,7 @@ } }, { - "id": 23, + "id": 21, "references": [ 4, 0 @@ -1816,7 +1788,7 @@ } }, { - "id": 24, + "id": 22, "references": [ 1 ], @@ -1912,7 +1884,7 @@ } }, { - "id": 25, + "id": 23, "references": [ 0 ], @@ -2076,10 +2048,10 @@ } }, { - "id": 26, + "id": 24, "references": [ 1, - 25 + 23 ], "type": "table", "data": { @@ -2150,7 +2122,7 @@ } }, { - "id": 27, + "id": 25, "references": [ 0 ], @@ -2294,10 +2266,10 @@ } }, { - "id": 28, + "id": 26, "references": [ 1, - 27 + 25 ], "type": "table", "data": { @@ -2471,7 +2443,7 @@ } }, { - "id": 29, + "id": 27, "references": [], "type": "table", "data": { @@ -2519,7 +2491,7 @@ } }, { - "id": 30, + "id": 28, "references": [], "type": "table", "data": { @@ -2694,7 +2666,7 @@ } }, { - "id": 31, + "id": 29, "references": [ 1 ], @@ -2788,7 +2760,7 @@ } }, { - "id": 32, + "id": 30, "references": [], "type": "table", "data": { @@ -2836,13 +2808,13 @@ } }, { - "id": 33, + "id": 31, "references": [ - 20 + 18 ], "type": "index", "data": { - "on": 20, + "on": 18, "name": "idx_partner_shared_with_id", "sql": "CREATE INDEX IF NOT EXISTS idx_partner_shared_with_id ON partner_entity (shared_with_id)", "unique": false, @@ -2850,19 +2822,47 @@ } }, { - "id": 34, + "id": 32, "references": [ - 21 + 19 ], "type": "index", "data": { - "on": 21, + "on": 19, "name": "idx_lat_lng", "sql": "CREATE INDEX IF NOT EXISTS idx_lat_lng ON remote_exif_entity (latitude, longitude)", "unique": false, "columns": [] } }, + { + "id": 33, + "references": [ + 19 + ], + "type": "index", + "data": { + "on": 19, + "name": "idx_remote_exif_city", + "sql": "CREATE INDEX IF NOT EXISTS idx_remote_exif_city\nON remote_exif_entity (city) WHERE city IS NOT NULL\n", + "unique": false, + "columns": [] + } + }, + { + "id": 34, + "references": [ + 20 + ], + "type": "index", + "data": { + "on": 20, + "name": "idx_remote_album_asset_album_asset", + "sql": "CREATE INDEX IF NOT EXISTS idx_remote_album_asset_album_asset ON remote_album_asset_entity (album_id, asset_id)", + "unique": false, + "columns": [] + } + }, { "id": 35, "references": [ @@ -2871,20 +2871,6 @@ "type": "index", "data": { "on": 22, - "name": "idx_remote_album_asset_album_asset", - "sql": "CREATE INDEX IF NOT EXISTS idx_remote_album_asset_album_asset ON remote_album_asset_entity (album_id, asset_id)", - "unique": false, - "columns": [] - } - }, - { - "id": 36, - "references": [ - 24 - ], - "type": "index", - "data": { - "on": 24, "name": "idx_remote_asset_cloud_id", "sql": "CREATE INDEX IF NOT EXISTS idx_remote_asset_cloud_id ON remote_asset_cloud_id_entity (cloud_id)", "unique": false, @@ -2892,13 +2878,13 @@ } }, { - "id": 37, + "id": 36, "references": [ - 27 + 25 ], "type": "index", "data": { - "on": 27, + "on": 25, "name": "idx_person_owner_id", "sql": "CREATE INDEX IF NOT EXISTS idx_person_owner_id ON person_entity (owner_id)", "unique": false, @@ -2906,13 +2892,13 @@ } }, { - "id": 38, + "id": 37, "references": [ - 28 + 26 ], "type": "index", "data": { - "on": 28, + "on": 26, "name": "idx_asset_face_person_id", "sql": "CREATE INDEX IF NOT EXISTS idx_asset_face_person_id ON asset_face_entity (person_id)", "unique": false, @@ -2920,13 +2906,13 @@ } }, { - "id": 39, + "id": 38, "references": [ - 28 + 26 ], "type": "index", "data": { - "on": 28, + "on": 26, "name": "idx_asset_face_asset_id", "sql": "CREATE INDEX IF NOT EXISTS idx_asset_face_asset_id ON asset_face_entity (asset_id)", "unique": false, @@ -2934,13 +2920,27 @@ } }, { - "id": 40, + "id": 39, "references": [ - 30 + 26 ], "type": "index", "data": { - "on": 30, + "on": 26, + "name": "idx_asset_face_visible_person", + "sql": "CREATE INDEX IF NOT EXISTS idx_asset_face_visible_person\nON asset_face_entity (person_id, asset_id)\nWHERE is_visible = 1 AND deleted_at IS NULL\n", + "unique": false, + "columns": [] + } + }, + { + "id": 40, + "references": [ + 28 + ], + "type": "index", + "data": { + "on": 28, "name": "idx_trashed_local_asset_checksum", "sql": "CREATE INDEX IF NOT EXISTS idx_trashed_local_asset_checksum ON trashed_local_asset_entity (checksum)", "unique": false, @@ -2950,11 +2950,11 @@ { "id": 41, "references": [ - 30 + 28 ], "type": "index", "data": { - "on": 30, + "on": 28, "name": "idx_trashed_local_asset_album", "sql": "CREATE INDEX IF NOT EXISTS idx_trashed_local_asset_album ON trashed_local_asset_entity (album_id)", "unique": false, @@ -2964,11 +2964,11 @@ { "id": 42, "references": [ - 31 + 29 ], "type": "index", "data": { - "on": 31, + "on": 29, "name": "idx_asset_edit_asset_id", "sql": "CREATE INDEX IF NOT EXISTS idx_asset_edit_asset_id ON asset_edit_entity (asset_id)", "unique": false, @@ -3076,15 +3076,6 @@ } ] }, - { - "name": "idx_remote_asset_owner_checksum", - "sql": [ - { - "dialect": "sqlite", - "sql": "CREATE INDEX IF NOT EXISTS idx_remote_asset_owner_checksum ON remote_asset_entity (owner_id, checksum)" - } - ] - }, { "name": "UQ_remote_assets_owner_checksum", "sql": [ @@ -3122,20 +3113,11 @@ ] }, { - "name": "idx_remote_asset_local_date_time_day", + "name": "idx_remote_asset_owner_visibility_deleted_created", "sql": [ { "dialect": "sqlite", - "sql": "CREATE INDEX IF NOT EXISTS idx_remote_asset_local_date_time_day ON remote_asset_entity (STRFTIME('%Y-%m-%d', local_date_time))" - } - ] - }, - { - "name": "idx_remote_asset_local_date_time_month", - "sql": [ - { - "dialect": "sqlite", - "sql": "CREATE INDEX IF NOT EXISTS idx_remote_asset_local_date_time_month ON remote_asset_entity (STRFTIME('%Y-%m', local_date_time))" + "sql": "CREATE INDEX IF NOT EXISTS idx_remote_asset_owner_visibility_deleted_created ON remote_asset_entity (owner_id, visibility, deleted_at, created_at DESC)" } ] }, @@ -3292,6 +3274,15 @@ } ] }, + { + "name": "idx_remote_exif_city", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE INDEX IF NOT EXISTS idx_remote_exif_city ON remote_exif_entity (city) WHERE city IS NOT NULL" + } + ] + }, { "name": "idx_remote_album_asset_album_asset", "sql": [ @@ -3337,6 +3328,15 @@ } ] }, + { + "name": "idx_asset_face_visible_person", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE INDEX IF NOT EXISTS idx_asset_face_visible_person ON asset_face_entity (person_id, asset_id) WHERE is_visible = 1 AND deleted_at IS NULL" + } + ] + }, { "name": "idx_trashed_local_asset_checksum", "sql": [ diff --git a/mobile/lib/infrastructure/entities/asset_face.entity.dart b/mobile/lib/infrastructure/entities/asset_face.entity.dart index 40fe9ab1c1..b94a0cf094 100644 --- a/mobile/lib/infrastructure/entities/asset_face.entity.dart +++ b/mobile/lib/infrastructure/entities/asset_face.entity.dart @@ -5,6 +5,11 @@ import 'package:immich_mobile/infrastructure/utils/drift_default.mixin.dart'; @TableIndex.sql('CREATE INDEX IF NOT EXISTS idx_asset_face_person_id ON asset_face_entity (person_id)') @TableIndex.sql('CREATE INDEX IF NOT EXISTS idx_asset_face_asset_id ON asset_face_entity (asset_id)') +@TableIndex.sql(''' +CREATE INDEX IF NOT EXISTS idx_asset_face_visible_person +ON asset_face_entity (person_id, asset_id) +WHERE is_visible = 1 AND deleted_at IS NULL +''') class AssetFaceEntity extends Table with DriftDefaultsMixin { const AssetFaceEntity(); diff --git a/mobile/lib/infrastructure/entities/asset_face.entity.drift.dart b/mobile/lib/infrastructure/entities/asset_face.entity.drift.dart index c97dd545a8..d262325742 100644 --- a/mobile/lib/infrastructure/entities/asset_face.entity.drift.dart +++ b/mobile/lib/infrastructure/entities/asset_face.entity.drift.dart @@ -1350,3 +1350,7 @@ i0.Index get idxAssetFaceAssetId => i0.Index( 'idx_asset_face_asset_id', 'CREATE INDEX IF NOT EXISTS idx_asset_face_asset_id ON asset_face_entity (asset_id)', ); +i0.Index get idxAssetFaceVisiblePerson => i0.Index( + 'idx_asset_face_visible_person', + 'CREATE INDEX IF NOT EXISTS idx_asset_face_visible_person ON asset_face_entity (person_id, asset_id) WHERE is_visible = 1 AND deleted_at IS NULL', +); diff --git a/mobile/lib/infrastructure/entities/exif.entity.dart b/mobile/lib/infrastructure/entities/exif.entity.dart index e009029ea7..120fbd0c68 100644 --- a/mobile/lib/infrastructure/entities/exif.entity.dart +++ b/mobile/lib/infrastructure/entities/exif.entity.dart @@ -6,6 +6,10 @@ import 'package:immich_mobile/infrastructure/utils/drift_default.mixin.dart'; import 'package:immich_mobile/infrastructure/utils/exif.converter.dart'; @TableIndex.sql('CREATE INDEX IF NOT EXISTS idx_lat_lng ON remote_exif_entity (latitude, longitude)') +@TableIndex.sql(''' +CREATE INDEX IF NOT EXISTS idx_remote_exif_city +ON remote_exif_entity (city) WHERE city IS NOT NULL +''') class RemoteExifEntity extends Table with DriftDefaultsMixin { const RemoteExifEntity(); diff --git a/mobile/lib/infrastructure/entities/exif.entity.drift.dart b/mobile/lib/infrastructure/entities/exif.entity.drift.dart index 8695e2004b..cbe31f5bb4 100644 --- a/mobile/lib/infrastructure/entities/exif.entity.drift.dart +++ b/mobile/lib/infrastructure/entities/exif.entity.drift.dart @@ -1883,3 +1883,8 @@ class RemoteExifEntityCompanion .toString(); } } + +i0.Index get idxRemoteExifCity => i0.Index( + 'idx_remote_exif_city', + 'CREATE INDEX IF NOT EXISTS idx_remote_exif_city ON remote_exif_entity (city) WHERE city IS NOT NULL', +); diff --git a/mobile/lib/infrastructure/entities/remote_asset.entity.dart b/mobile/lib/infrastructure/entities/remote_asset.entity.dart index 1050081b46..8644667168 100644 --- a/mobile/lib/infrastructure/entities/remote_asset.entity.dart +++ b/mobile/lib/infrastructure/entities/remote_asset.entity.dart @@ -5,9 +5,6 @@ import 'package:immich_mobile/infrastructure/entities/user.entity.dart'; import 'package:immich_mobile/infrastructure/utils/asset.mixin.dart'; import 'package:immich_mobile/infrastructure/utils/drift_default.mixin.dart'; -@TableIndex.sql( - 'CREATE INDEX IF NOT EXISTS idx_remote_asset_owner_checksum ON remote_asset_entity (owner_id, checksum)', -) @TableIndex.sql(''' CREATE UNIQUE INDEX IF NOT EXISTS UQ_remote_assets_owner_checksum ON remote_asset_entity (owner_id, checksum) @@ -20,12 +17,10 @@ WHERE (library_id IS NOT NULL); ''') @TableIndex.sql('CREATE INDEX IF NOT EXISTS idx_remote_asset_checksum ON remote_asset_entity (checksum)') @TableIndex.sql('CREATE INDEX IF NOT EXISTS idx_remote_asset_stack_id ON remote_asset_entity (stack_id)') -@TableIndex.sql( - "CREATE INDEX IF NOT EXISTS idx_remote_asset_local_date_time_day ON remote_asset_entity (STRFTIME('%Y-%m-%d', local_date_time))", -) -@TableIndex.sql( - "CREATE INDEX IF NOT EXISTS idx_remote_asset_local_date_time_month ON remote_asset_entity (STRFTIME('%Y-%m', local_date_time))", -) +@TableIndex.sql(''' +CREATE INDEX IF NOT EXISTS idx_remote_asset_owner_visibility_deleted_created +ON remote_asset_entity (owner_id, visibility, deleted_at, created_at DESC) +''') class RemoteAssetEntity extends Table with DriftDefaultsMixin, AssetEntityMixin { const RemoteAssetEntity(); diff --git a/mobile/lib/infrastructure/entities/remote_asset.entity.drift.dart b/mobile/lib/infrastructure/entities/remote_asset.entity.drift.dart index a2333696b0..8141573343 100644 --- a/mobile/lib/infrastructure/entities/remote_asset.entity.drift.dart +++ b/mobile/lib/infrastructure/entities/remote_asset.entity.drift.dart @@ -666,9 +666,9 @@ typedef $$RemoteAssetEntityTableProcessedTableManager = i1.RemoteAssetEntityData, i0.PrefetchHooks Function({bool ownerId}) >; -i0.Index get idxRemoteAssetOwnerChecksum => i0.Index( - 'idx_remote_asset_owner_checksum', - 'CREATE INDEX IF NOT EXISTS idx_remote_asset_owner_checksum ON remote_asset_entity (owner_id, checksum)', +i0.Index get uQRemoteAssetsOwnerChecksum => i0.Index( + 'UQ_remote_assets_owner_checksum', + 'CREATE UNIQUE INDEX IF NOT EXISTS UQ_remote_assets_owner_checksum ON remote_asset_entity (owner_id, checksum) WHERE(library_id IS NULL)', ); class $RemoteAssetEntityTable extends i3.RemoteAssetEntity @@ -1763,10 +1763,6 @@ class RemoteAssetEntityCompanion } } -i0.Index get uQRemoteAssetsOwnerChecksum => i0.Index( - 'UQ_remote_assets_owner_checksum', - 'CREATE UNIQUE INDEX IF NOT EXISTS UQ_remote_assets_owner_checksum ON remote_asset_entity (owner_id, checksum) WHERE(library_id IS NULL)', -); i0.Index get uQRemoteAssetsOwnerLibraryChecksum => i0.Index( 'UQ_remote_assets_owner_library_checksum', 'CREATE UNIQUE INDEX IF NOT EXISTS UQ_remote_assets_owner_library_checksum ON remote_asset_entity (owner_id, library_id, checksum) WHERE(library_id IS NOT NULL)', @@ -1779,11 +1775,7 @@ i0.Index get idxRemoteAssetStackId => i0.Index( 'idx_remote_asset_stack_id', 'CREATE INDEX IF NOT EXISTS idx_remote_asset_stack_id ON remote_asset_entity (stack_id)', ); -i0.Index get idxRemoteAssetLocalDateTimeDay => i0.Index( - 'idx_remote_asset_local_date_time_day', - 'CREATE INDEX IF NOT EXISTS idx_remote_asset_local_date_time_day ON remote_asset_entity (STRFTIME(\'%Y-%m-%d\', local_date_time))', -); -i0.Index get idxRemoteAssetLocalDateTimeMonth => i0.Index( - 'idx_remote_asset_local_date_time_month', - 'CREATE INDEX IF NOT EXISTS idx_remote_asset_local_date_time_month ON remote_asset_entity (STRFTIME(\'%Y-%m\', local_date_time))', +i0.Index get idxRemoteAssetOwnerVisibilityDeletedCreated => i0.Index( + 'idx_remote_asset_owner_visibility_deleted_created', + 'CREATE INDEX IF NOT EXISTS idx_remote_asset_owner_visibility_deleted_created ON remote_asset_entity (owner_id, visibility, deleted_at, created_at DESC)', ); diff --git a/mobile/lib/infrastructure/repositories/db.repository.dart b/mobile/lib/infrastructure/repositories/db.repository.dart index 2e3df13d38..e81fe58ba9 100644 --- a/mobile/lib/infrastructure/repositories/db.repository.dart +++ b/mobile/lib/infrastructure/repositories/db.repository.dart @@ -266,6 +266,12 @@ class Drift extends $Drift { }, from24To25: (m, v25) async { await m.createTable(v25.metadata); + await customStatement('DROP INDEX IF EXISTS idx_remote_asset_owner_checksum'); + await customStatement('DROP INDEX IF EXISTS idx_remote_asset_local_date_time_day'); + await customStatement('DROP INDEX IF EXISTS idx_remote_asset_local_date_time_month'); + await m.createIndex(v25.idxRemoteAssetOwnerVisibilityDeletedCreated); + await m.createIndex(v25.idxRemoteExifCity); + await m.createIndex(v25.idxAssetFaceVisiblePerson); }, from25To26: (m, v26) async { await m.addColumn(v26.remoteAssetEntity, v26.remoteAssetEntity.uploadedAt); diff --git a/mobile/lib/infrastructure/repositories/db.repository.drift.dart b/mobile/lib/infrastructure/repositories/db.repository.drift.dart index 01f44372fb..c43a83f86a 100644 --- a/mobile/lib/infrastructure/repositories/db.repository.drift.dart +++ b/mobile/lib/infrastructure/repositories/db.repository.drift.dart @@ -113,13 +113,11 @@ abstract class $Drift extends i0.GeneratedDatabase { i4.idxLocalAssetChecksum, i4.idxLocalAssetCloudId, i3.idxStackPrimaryAssetId, - i2.idxRemoteAssetOwnerChecksum, i2.uQRemoteAssetsOwnerChecksum, i2.uQRemoteAssetsOwnerLibraryChecksum, i2.idxRemoteAssetChecksum, i2.idxRemoteAssetStackId, - i2.idxRemoteAssetLocalDateTimeDay, - i2.idxRemoteAssetLocalDateTimeMonth, + i2.idxRemoteAssetOwnerVisibilityDeletedCreated, authUserEntity, userMetadataEntity, partnerEntity, @@ -137,11 +135,13 @@ abstract class $Drift extends i0.GeneratedDatabase { metadataEntity, i10.idxPartnerSharedWithId, i11.idxLatLng, + i11.idxRemoteExifCity, i12.idxRemoteAlbumAssetAlbumAsset, i14.idxRemoteAssetCloudId, i17.idxPersonOwnerId, i18.idxAssetFacePersonId, i18.idxAssetFaceAssetId, + i18.idxAssetFaceVisiblePerson, i20.idxTrashedLocalAssetChecksum, i20.idxTrashedLocalAssetAlbum, i21.idxAssetEditAssetId, diff --git a/mobile/lib/infrastructure/repositories/db.repository.steps.dart b/mobile/lib/infrastructure/repositories/db.repository.steps.dart index 21d915f8af..1fb88de1d0 100644 --- a/mobile/lib/infrastructure/repositories/db.repository.steps.dart +++ b/mobile/lib/infrastructure/repositories/db.repository.steps.dart @@ -12390,13 +12390,11 @@ final class Schema25 extends i0.VersionedSchema { idxLocalAssetChecksum, idxLocalAssetCloudId, idxStackPrimaryAssetId, - idxRemoteAssetOwnerChecksum, uQRemoteAssetsOwnerChecksum, uQRemoteAssetsOwnerLibraryChecksum, idxRemoteAssetChecksum, idxRemoteAssetStackId, - idxRemoteAssetLocalDateTimeDay, - idxRemoteAssetLocalDateTimeMonth, + idxRemoteAssetOwnerVisibilityDeletedCreated, authUserEntity, userMetadataEntity, partnerEntity, @@ -12414,11 +12412,13 @@ final class Schema25 extends i0.VersionedSchema { metadata, idxPartnerSharedWithId, idxLatLng, + idxRemoteExifCity, idxRemoteAlbumAssetAlbumAsset, idxRemoteAssetCloudId, idxPersonOwnerId, idxAssetFacePersonId, idxAssetFaceAssetId, + idxAssetFaceVisiblePerson, idxTrashedLocalAssetChecksum, idxTrashedLocalAssetAlbum, idxAssetEditAssetId, @@ -12583,10 +12583,6 @@ final class Schema25 extends i0.VersionedSchema { 'idx_stack_primary_asset_id', 'CREATE INDEX IF NOT EXISTS idx_stack_primary_asset_id ON stack_entity (primary_asset_id)', ); - final i1.Index idxRemoteAssetOwnerChecksum = i1.Index( - 'idx_remote_asset_owner_checksum', - 'CREATE INDEX IF NOT EXISTS idx_remote_asset_owner_checksum ON remote_asset_entity (owner_id, checksum)', - ); final i1.Index uQRemoteAssetsOwnerChecksum = i1.Index( 'UQ_remote_assets_owner_checksum', 'CREATE UNIQUE INDEX IF NOT EXISTS UQ_remote_assets_owner_checksum ON remote_asset_entity (owner_id, checksum) WHERE(library_id IS NULL)', @@ -12603,13 +12599,9 @@ final class Schema25 extends i0.VersionedSchema { 'idx_remote_asset_stack_id', 'CREATE INDEX IF NOT EXISTS idx_remote_asset_stack_id ON remote_asset_entity (stack_id)', ); - final i1.Index idxRemoteAssetLocalDateTimeDay = i1.Index( - 'idx_remote_asset_local_date_time_day', - 'CREATE INDEX IF NOT EXISTS idx_remote_asset_local_date_time_day ON remote_asset_entity (STRFTIME(\'%Y-%m-%d\', local_date_time))', - ); - final i1.Index idxRemoteAssetLocalDateTimeMonth = i1.Index( - 'idx_remote_asset_local_date_time_month', - 'CREATE INDEX IF NOT EXISTS idx_remote_asset_local_date_time_month ON remote_asset_entity (STRFTIME(\'%Y-%m\', local_date_time))', + final i1.Index idxRemoteAssetOwnerVisibilityDeletedCreated = i1.Index( + 'idx_remote_asset_owner_visibility_deleted_created', + 'CREATE INDEX IF NOT EXISTS idx_remote_asset_owner_visibility_deleted_created ON remote_asset_entity (owner_id, visibility, deleted_at, created_at DESC)', ); late final Shape40 authUserEntity = Shape40( source: i0.VersionedTable( @@ -12883,6 +12875,10 @@ final class Schema25 extends i0.VersionedSchema { 'idx_lat_lng', 'CREATE INDEX IF NOT EXISTS idx_lat_lng ON remote_exif_entity (latitude, longitude)', ); + final i1.Index idxRemoteExifCity = i1.Index( + 'idx_remote_exif_city', + 'CREATE INDEX IF NOT EXISTS idx_remote_exif_city ON remote_exif_entity (city) WHERE city IS NOT NULL', + ); final i1.Index idxRemoteAlbumAssetAlbumAsset = i1.Index( 'idx_remote_album_asset_album_asset', 'CREATE INDEX IF NOT EXISTS idx_remote_album_asset_album_asset ON remote_album_asset_entity (album_id, asset_id)', @@ -12903,6 +12899,10 @@ final class Schema25 extends i0.VersionedSchema { 'idx_asset_face_asset_id', 'CREATE INDEX IF NOT EXISTS idx_asset_face_asset_id ON asset_face_entity (asset_id)', ); + final i1.Index idxAssetFaceVisiblePerson = i1.Index( + 'idx_asset_face_visible_person', + 'CREATE INDEX IF NOT EXISTS idx_asset_face_visible_person ON asset_face_entity (person_id, asset_id) WHERE is_visible = 1 AND deleted_at IS NULL', + ); final i1.Index idxTrashedLocalAssetChecksum = i1.Index( 'idx_trashed_local_asset_checksum', 'CREATE INDEX IF NOT EXISTS idx_trashed_local_asset_checksum ON trashed_local_asset_entity (checksum)', @@ -12959,13 +12959,11 @@ final class Schema26 extends i0.VersionedSchema { idxLocalAssetChecksum, idxLocalAssetCloudId, idxStackPrimaryAssetId, - idxRemoteAssetOwnerChecksum, uQRemoteAssetsOwnerChecksum, uQRemoteAssetsOwnerLibraryChecksum, idxRemoteAssetChecksum, idxRemoteAssetStackId, - idxRemoteAssetLocalDateTimeDay, - idxRemoteAssetLocalDateTimeMonth, + idxRemoteAssetOwnerVisibilityDeletedCreated, authUserEntity, userMetadataEntity, partnerEntity, @@ -12983,11 +12981,13 @@ final class Schema26 extends i0.VersionedSchema { metadata, idxPartnerSharedWithId, idxLatLng, + idxRemoteExifCity, idxRemoteAlbumAssetAlbumAsset, idxRemoteAssetCloudId, idxPersonOwnerId, idxAssetFacePersonId, idxAssetFaceAssetId, + idxAssetFaceVisiblePerson, idxTrashedLocalAssetChecksum, idxTrashedLocalAssetAlbum, idxAssetEditAssetId, @@ -13153,10 +13153,6 @@ final class Schema26 extends i0.VersionedSchema { 'idx_stack_primary_asset_id', 'CREATE INDEX IF NOT EXISTS idx_stack_primary_asset_id ON stack_entity (primary_asset_id)', ); - final i1.Index idxRemoteAssetOwnerChecksum = i1.Index( - 'idx_remote_asset_owner_checksum', - 'CREATE INDEX IF NOT EXISTS idx_remote_asset_owner_checksum ON remote_asset_entity (owner_id, checksum)', - ); final i1.Index uQRemoteAssetsOwnerChecksum = i1.Index( 'UQ_remote_assets_owner_checksum', 'CREATE UNIQUE INDEX IF NOT EXISTS UQ_remote_assets_owner_checksum ON remote_asset_entity (owner_id, checksum) WHERE(library_id IS NULL)', @@ -13173,13 +13169,9 @@ final class Schema26 extends i0.VersionedSchema { 'idx_remote_asset_stack_id', 'CREATE INDEX IF NOT EXISTS idx_remote_asset_stack_id ON remote_asset_entity (stack_id)', ); - final i1.Index idxRemoteAssetLocalDateTimeDay = i1.Index( - 'idx_remote_asset_local_date_time_day', - 'CREATE INDEX IF NOT EXISTS idx_remote_asset_local_date_time_day ON remote_asset_entity (STRFTIME(\'%Y-%m-%d\', local_date_time))', - ); - final i1.Index idxRemoteAssetLocalDateTimeMonth = i1.Index( - 'idx_remote_asset_local_date_time_month', - 'CREATE INDEX IF NOT EXISTS idx_remote_asset_local_date_time_month ON remote_asset_entity (STRFTIME(\'%Y-%m\', local_date_time))', + final i1.Index idxRemoteAssetOwnerVisibilityDeletedCreated = i1.Index( + 'idx_remote_asset_owner_visibility_deleted_created', + 'CREATE INDEX IF NOT EXISTS idx_remote_asset_owner_visibility_deleted_created ON remote_asset_entity (owner_id, visibility, deleted_at, created_at DESC)', ); late final Shape40 authUserEntity = Shape40( source: i0.VersionedTable( @@ -13453,6 +13445,10 @@ final class Schema26 extends i0.VersionedSchema { 'idx_lat_lng', 'CREATE INDEX IF NOT EXISTS idx_lat_lng ON remote_exif_entity (latitude, longitude)', ); + final i1.Index idxRemoteExifCity = i1.Index( + 'idx_remote_exif_city', + 'CREATE INDEX IF NOT EXISTS idx_remote_exif_city ON remote_exif_entity (city) WHERE city IS NOT NULL', + ); final i1.Index idxRemoteAlbumAssetAlbumAsset = i1.Index( 'idx_remote_album_asset_album_asset', 'CREATE INDEX IF NOT EXISTS idx_remote_album_asset_album_asset ON remote_album_asset_entity (album_id, asset_id)', @@ -13473,6 +13469,10 @@ final class Schema26 extends i0.VersionedSchema { 'idx_asset_face_asset_id', 'CREATE INDEX IF NOT EXISTS idx_asset_face_asset_id ON asset_face_entity (asset_id)', ); + final i1.Index idxAssetFaceVisiblePerson = i1.Index( + 'idx_asset_face_visible_person', + 'CREATE INDEX IF NOT EXISTS idx_asset_face_visible_person ON asset_face_entity (person_id, asset_id) WHERE is_visible = 1 AND deleted_at IS NULL', + ); final i1.Index idxTrashedLocalAssetChecksum = i1.Index( 'idx_trashed_local_asset_checksum', 'CREATE INDEX IF NOT EXISTS idx_trashed_local_asset_checksum ON trashed_local_asset_entity (checksum)', diff --git a/mobile/test/drift/main/generated/schema_v25.dart b/mobile/test/drift/main/generated/schema_v25.dart index 932b50498c..aad45f0bd3 100644 --- a/mobile/test/drift/main/generated/schema_v25.dart +++ b/mobile/test/drift/main/generated/schema_v25.dart @@ -9030,10 +9030,6 @@ class DatabaseAtV25 extends GeneratedDatabase { 'idx_stack_primary_asset_id', 'CREATE INDEX IF NOT EXISTS idx_stack_primary_asset_id ON stack_entity (primary_asset_id)', ); - late final Index idxRemoteAssetOwnerChecksum = Index( - 'idx_remote_asset_owner_checksum', - 'CREATE INDEX IF NOT EXISTS idx_remote_asset_owner_checksum ON remote_asset_entity (owner_id, checksum)', - ); late final Index uQRemoteAssetsOwnerChecksum = Index( 'UQ_remote_assets_owner_checksum', 'CREATE UNIQUE INDEX IF NOT EXISTS UQ_remote_assets_owner_checksum ON remote_asset_entity (owner_id, checksum) WHERE(library_id IS NULL)', @@ -9050,13 +9046,9 @@ class DatabaseAtV25 extends GeneratedDatabase { 'idx_remote_asset_stack_id', 'CREATE INDEX IF NOT EXISTS idx_remote_asset_stack_id ON remote_asset_entity (stack_id)', ); - late final Index idxRemoteAssetLocalDateTimeDay = Index( - 'idx_remote_asset_local_date_time_day', - 'CREATE INDEX IF NOT EXISTS idx_remote_asset_local_date_time_day ON remote_asset_entity (STRFTIME(\'%Y-%m-%d\', local_date_time))', - ); - late final Index idxRemoteAssetLocalDateTimeMonth = Index( - 'idx_remote_asset_local_date_time_month', - 'CREATE INDEX IF NOT EXISTS idx_remote_asset_local_date_time_month ON remote_asset_entity (STRFTIME(\'%Y-%m\', local_date_time))', + late final Index idxRemoteAssetOwnerVisibilityDeletedCreated = Index( + 'idx_remote_asset_owner_visibility_deleted_created', + 'CREATE INDEX IF NOT EXISTS idx_remote_asset_owner_visibility_deleted_created ON remote_asset_entity (owner_id, visibility, deleted_at, created_at DESC)', ); late final AuthUserEntity authUserEntity = AuthUserEntity(this); late final UserMetadataEntity userMetadataEntity = UserMetadataEntity(this); @@ -9085,6 +9077,10 @@ class DatabaseAtV25 extends GeneratedDatabase { 'idx_lat_lng', 'CREATE INDEX IF NOT EXISTS idx_lat_lng ON remote_exif_entity (latitude, longitude)', ); + late final Index idxRemoteExifCity = Index( + 'idx_remote_exif_city', + 'CREATE INDEX IF NOT EXISTS idx_remote_exif_city ON remote_exif_entity (city) WHERE city IS NOT NULL', + ); late final Index idxRemoteAlbumAssetAlbumAsset = Index( 'idx_remote_album_asset_album_asset', 'CREATE INDEX IF NOT EXISTS idx_remote_album_asset_album_asset ON remote_album_asset_entity (album_id, asset_id)', @@ -9105,6 +9101,10 @@ class DatabaseAtV25 extends GeneratedDatabase { 'idx_asset_face_asset_id', 'CREATE INDEX IF NOT EXISTS idx_asset_face_asset_id ON asset_face_entity (asset_id)', ); + late final Index idxAssetFaceVisiblePerson = Index( + 'idx_asset_face_visible_person', + 'CREATE INDEX IF NOT EXISTS idx_asset_face_visible_person ON asset_face_entity (person_id, asset_id) WHERE is_visible = 1 AND deleted_at IS NULL', + ); late final Index idxTrashedLocalAssetChecksum = Index( 'idx_trashed_local_asset_checksum', 'CREATE INDEX IF NOT EXISTS idx_trashed_local_asset_checksum ON trashed_local_asset_entity (checksum)', @@ -9133,13 +9133,11 @@ class DatabaseAtV25 extends GeneratedDatabase { idxLocalAssetChecksum, idxLocalAssetCloudId, idxStackPrimaryAssetId, - idxRemoteAssetOwnerChecksum, uQRemoteAssetsOwnerChecksum, uQRemoteAssetsOwnerLibraryChecksum, idxRemoteAssetChecksum, idxRemoteAssetStackId, - idxRemoteAssetLocalDateTimeDay, - idxRemoteAssetLocalDateTimeMonth, + idxRemoteAssetOwnerVisibilityDeletedCreated, authUserEntity, userMetadataEntity, partnerEntity, @@ -9157,11 +9155,13 @@ class DatabaseAtV25 extends GeneratedDatabase { metadata, idxPartnerSharedWithId, idxLatLng, + idxRemoteExifCity, idxRemoteAlbumAssetAlbumAsset, idxRemoteAssetCloudId, idxPersonOwnerId, idxAssetFacePersonId, idxAssetFaceAssetId, + idxAssetFaceVisiblePerson, idxTrashedLocalAssetChecksum, idxTrashedLocalAssetAlbum, idxAssetEditAssetId, diff --git a/mobile/test/drift/main/generated/schema_v26.dart b/mobile/test/drift/main/generated/schema_v26.dart index f9e3af5d7c..b91afd1b8a 100644 --- a/mobile/test/drift/main/generated/schema_v26.dart +++ b/mobile/test/drift/main/generated/schema_v26.dart @@ -9069,10 +9069,6 @@ class DatabaseAtV26 extends GeneratedDatabase { 'idx_stack_primary_asset_id', 'CREATE INDEX IF NOT EXISTS idx_stack_primary_asset_id ON stack_entity (primary_asset_id)', ); - late final Index idxRemoteAssetOwnerChecksum = Index( - 'idx_remote_asset_owner_checksum', - 'CREATE INDEX IF NOT EXISTS idx_remote_asset_owner_checksum ON remote_asset_entity (owner_id, checksum)', - ); late final Index uQRemoteAssetsOwnerChecksum = Index( 'UQ_remote_assets_owner_checksum', 'CREATE UNIQUE INDEX IF NOT EXISTS UQ_remote_assets_owner_checksum ON remote_asset_entity (owner_id, checksum) WHERE(library_id IS NULL)', @@ -9089,13 +9085,9 @@ class DatabaseAtV26 extends GeneratedDatabase { 'idx_remote_asset_stack_id', 'CREATE INDEX IF NOT EXISTS idx_remote_asset_stack_id ON remote_asset_entity (stack_id)', ); - late final Index idxRemoteAssetLocalDateTimeDay = Index( - 'idx_remote_asset_local_date_time_day', - 'CREATE INDEX IF NOT EXISTS idx_remote_asset_local_date_time_day ON remote_asset_entity (STRFTIME(\'%Y-%m-%d\', local_date_time))', - ); - late final Index idxRemoteAssetLocalDateTimeMonth = Index( - 'idx_remote_asset_local_date_time_month', - 'CREATE INDEX IF NOT EXISTS idx_remote_asset_local_date_time_month ON remote_asset_entity (STRFTIME(\'%Y-%m\', local_date_time))', + late final Index idxRemoteAssetOwnerVisibilityDeletedCreated = Index( + 'idx_remote_asset_owner_visibility_deleted_created', + 'CREATE INDEX IF NOT EXISTS idx_remote_asset_owner_visibility_deleted_created ON remote_asset_entity (owner_id, visibility, deleted_at, created_at DESC)', ); late final AuthUserEntity authUserEntity = AuthUserEntity(this); late final UserMetadataEntity userMetadataEntity = UserMetadataEntity(this); @@ -9124,6 +9116,10 @@ class DatabaseAtV26 extends GeneratedDatabase { 'idx_lat_lng', 'CREATE INDEX IF NOT EXISTS idx_lat_lng ON remote_exif_entity (latitude, longitude)', ); + late final Index idxRemoteExifCity = Index( + 'idx_remote_exif_city', + 'CREATE INDEX IF NOT EXISTS idx_remote_exif_city ON remote_exif_entity (city) WHERE city IS NOT NULL', + ); late final Index idxRemoteAlbumAssetAlbumAsset = Index( 'idx_remote_album_asset_album_asset', 'CREATE INDEX IF NOT EXISTS idx_remote_album_asset_album_asset ON remote_album_asset_entity (album_id, asset_id)', @@ -9144,6 +9140,10 @@ class DatabaseAtV26 extends GeneratedDatabase { 'idx_asset_face_asset_id', 'CREATE INDEX IF NOT EXISTS idx_asset_face_asset_id ON asset_face_entity (asset_id)', ); + late final Index idxAssetFaceVisiblePerson = Index( + 'idx_asset_face_visible_person', + 'CREATE INDEX IF NOT EXISTS idx_asset_face_visible_person ON asset_face_entity (person_id, asset_id) WHERE is_visible = 1 AND deleted_at IS NULL', + ); late final Index idxTrashedLocalAssetChecksum = Index( 'idx_trashed_local_asset_checksum', 'CREATE INDEX IF NOT EXISTS idx_trashed_local_asset_checksum ON trashed_local_asset_entity (checksum)', @@ -9172,13 +9172,11 @@ class DatabaseAtV26 extends GeneratedDatabase { idxLocalAssetChecksum, idxLocalAssetCloudId, idxStackPrimaryAssetId, - idxRemoteAssetOwnerChecksum, uQRemoteAssetsOwnerChecksum, uQRemoteAssetsOwnerLibraryChecksum, idxRemoteAssetChecksum, idxRemoteAssetStackId, - idxRemoteAssetLocalDateTimeDay, - idxRemoteAssetLocalDateTimeMonth, + idxRemoteAssetOwnerVisibilityDeletedCreated, authUserEntity, userMetadataEntity, partnerEntity, @@ -9196,11 +9194,13 @@ class DatabaseAtV26 extends GeneratedDatabase { metadata, idxPartnerSharedWithId, idxLatLng, + idxRemoteExifCity, idxRemoteAlbumAssetAlbumAsset, idxRemoteAssetCloudId, idxPersonOwnerId, idxAssetFacePersonId, idxAssetFaceAssetId, + idxAssetFaceVisiblePerson, idxTrashedLocalAssetChecksum, idxTrashedLocalAssetAlbum, idxAssetEditAssetId,