mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
fix(mobile): add partial index based on library ID to remote assets (#20214)
* feat: add libraryId to SyncAssetV1 * add partial index # Conflicts: # mobile/drift_schemas/main/drift_schema_v5.json # mobile/lib/infrastructure/repositories/db.repository.dart # mobile/lib/infrastructure/repositories/db.repository.steps.dart # mobile/test/drift/main/generated/schema_v5.dart * chore: make build * rebase --------- Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
parent
f85d8add01
commit
641a3baadd
18 changed files with 6985 additions and 11 deletions
|
|
@ -30,6 +30,7 @@ typedef $$RemoteAssetEntityTableCreateCompanionBuilder =
|
|||
i0.Value<String?> livePhotoVideoId,
|
||||
required i2.AssetVisibility visibility,
|
||||
i0.Value<String?> stackId,
|
||||
i0.Value<String?> libraryId,
|
||||
});
|
||||
typedef $$RemoteAssetEntityTableUpdateCompanionBuilder =
|
||||
i1.RemoteAssetEntityCompanion Function({
|
||||
|
|
@ -50,6 +51,7 @@ typedef $$RemoteAssetEntityTableUpdateCompanionBuilder =
|
|||
i0.Value<String?> livePhotoVideoId,
|
||||
i0.Value<i2.AssetVisibility> visibility,
|
||||
i0.Value<String?> stackId,
|
||||
i0.Value<String?> libraryId,
|
||||
});
|
||||
|
||||
final class $$RemoteAssetEntityTableReferences
|
||||
|
|
@ -189,6 +191,11 @@ class $$RemoteAssetEntityTableFilterComposer
|
|||
builder: (column) => i0.ColumnFilters(column),
|
||||
);
|
||||
|
||||
i0.ColumnFilters<String> get libraryId => $composableBuilder(
|
||||
column: $table.libraryId,
|
||||
builder: (column) => i0.ColumnFilters(column),
|
||||
);
|
||||
|
||||
i5.$$UserEntityTableFilterComposer get ownerId {
|
||||
final i5.$$UserEntityTableFilterComposer composer = $composerBuilder(
|
||||
composer: this,
|
||||
|
|
@ -306,6 +313,11 @@ class $$RemoteAssetEntityTableOrderingComposer
|
|||
builder: (column) => i0.ColumnOrderings(column),
|
||||
);
|
||||
|
||||
i0.ColumnOrderings<String> get libraryId => $composableBuilder(
|
||||
column: $table.libraryId,
|
||||
builder: (column) => i0.ColumnOrderings(column),
|
||||
);
|
||||
|
||||
i5.$$UserEntityTableOrderingComposer get ownerId {
|
||||
final i5.$$UserEntityTableOrderingComposer composer = $composerBuilder(
|
||||
composer: this,
|
||||
|
|
@ -402,6 +414,9 @@ class $$RemoteAssetEntityTableAnnotationComposer
|
|||
i0.GeneratedColumn<String> get stackId =>
|
||||
$composableBuilder(column: $table.stackId, builder: (column) => column);
|
||||
|
||||
i0.GeneratedColumn<String> get libraryId =>
|
||||
$composableBuilder(column: $table.libraryId, builder: (column) => column);
|
||||
|
||||
i5.$$UserEntityTableAnnotationComposer get ownerId {
|
||||
final i5.$$UserEntityTableAnnotationComposer composer = $composerBuilder(
|
||||
composer: this,
|
||||
|
|
@ -481,6 +496,7 @@ class $$RemoteAssetEntityTableTableManager
|
|||
i0.Value<i2.AssetVisibility> visibility =
|
||||
const i0.Value.absent(),
|
||||
i0.Value<String?> stackId = const i0.Value.absent(),
|
||||
i0.Value<String?> libraryId = const i0.Value.absent(),
|
||||
}) => i1.RemoteAssetEntityCompanion(
|
||||
name: name,
|
||||
type: type,
|
||||
|
|
@ -499,6 +515,7 @@ class $$RemoteAssetEntityTableTableManager
|
|||
livePhotoVideoId: livePhotoVideoId,
|
||||
visibility: visibility,
|
||||
stackId: stackId,
|
||||
libraryId: libraryId,
|
||||
),
|
||||
createCompanionCallback:
|
||||
({
|
||||
|
|
@ -519,6 +536,7 @@ class $$RemoteAssetEntityTableTableManager
|
|||
i0.Value<String?> livePhotoVideoId = const i0.Value.absent(),
|
||||
required i2.AssetVisibility visibility,
|
||||
i0.Value<String?> stackId = const i0.Value.absent(),
|
||||
i0.Value<String?> libraryId = const i0.Value.absent(),
|
||||
}) => i1.RemoteAssetEntityCompanion.insert(
|
||||
name: name,
|
||||
type: type,
|
||||
|
|
@ -537,6 +555,7 @@ class $$RemoteAssetEntityTableTableManager
|
|||
livePhotoVideoId: livePhotoVideoId,
|
||||
visibility: visibility,
|
||||
stackId: stackId,
|
||||
libraryId: libraryId,
|
||||
),
|
||||
withReferenceMapper: (p0) => p0
|
||||
.map(
|
||||
|
|
@ -607,9 +626,9 @@ typedef $$RemoteAssetEntityTableProcessedTableManager =
|
|||
i1.RemoteAssetEntityData,
|
||||
i0.PrefetchHooks Function({bool ownerId})
|
||||
>;
|
||||
i0.Index get uQRemoteAssetOwnerChecksum => i0.Index(
|
||||
'UQ_remote_asset_owner_checksum',
|
||||
'CREATE UNIQUE INDEX UQ_remote_asset_owner_checksum ON remote_asset_entity (checksum, owner_id)',
|
||||
i0.Index get idxRemoteAssetOwnerChecksum => i0.Index(
|
||||
'idx_remote_asset_owner_checksum',
|
||||
'CREATE INDEX idx_remote_asset_owner_checksum ON remote_asset_entity (owner_id, checksum)',
|
||||
);
|
||||
|
||||
class $RemoteAssetEntityTable extends i3.RemoteAssetEntity
|
||||
|
|
@ -814,6 +833,17 @@ class $RemoteAssetEntityTable extends i3.RemoteAssetEntity
|
|||
type: i0.DriftSqlType.string,
|
||||
requiredDuringInsert: false,
|
||||
);
|
||||
static const i0.VerificationMeta _libraryIdMeta = const i0.VerificationMeta(
|
||||
'libraryId',
|
||||
);
|
||||
@override
|
||||
late final i0.GeneratedColumn<String> libraryId = i0.GeneratedColumn<String>(
|
||||
'library_id',
|
||||
aliasedName,
|
||||
true,
|
||||
type: i0.DriftSqlType.string,
|
||||
requiredDuringInsert: false,
|
||||
);
|
||||
@override
|
||||
List<i0.GeneratedColumn> get $columns => [
|
||||
name,
|
||||
|
|
@ -833,6 +863,7 @@ class $RemoteAssetEntityTable extends i3.RemoteAssetEntity
|
|||
livePhotoVideoId,
|
||||
visibility,
|
||||
stackId,
|
||||
libraryId,
|
||||
];
|
||||
@override
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
|
|
@ -950,6 +981,12 @@ class $RemoteAssetEntityTable extends i3.RemoteAssetEntity
|
|||
stackId.isAcceptableOrUnknown(data['stack_id']!, _stackIdMeta),
|
||||
);
|
||||
}
|
||||
if (data.containsKey('library_id')) {
|
||||
context.handle(
|
||||
_libraryIdMeta,
|
||||
libraryId.isAcceptableOrUnknown(data['library_id']!, _libraryIdMeta),
|
||||
);
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
|
|
@ -1034,6 +1071,10 @@ class $RemoteAssetEntityTable extends i3.RemoteAssetEntity
|
|||
i0.DriftSqlType.string,
|
||||
data['${effectivePrefix}stack_id'],
|
||||
),
|
||||
libraryId: attachedDatabase.typeMapping.read(
|
||||
i0.DriftSqlType.string,
|
||||
data['${effectivePrefix}library_id'],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -1073,6 +1114,7 @@ class RemoteAssetEntityData extends i0.DataClass
|
|||
final String? livePhotoVideoId;
|
||||
final i2.AssetVisibility visibility;
|
||||
final String? stackId;
|
||||
final String? libraryId;
|
||||
const RemoteAssetEntityData({
|
||||
required this.name,
|
||||
required this.type,
|
||||
|
|
@ -1091,6 +1133,7 @@ class RemoteAssetEntityData extends i0.DataClass
|
|||
this.livePhotoVideoId,
|
||||
required this.visibility,
|
||||
this.stackId,
|
||||
this.libraryId,
|
||||
});
|
||||
@override
|
||||
Map<String, i0.Expression> toColumns(bool nullToAbsent) {
|
||||
|
|
@ -1136,6 +1179,9 @@ class RemoteAssetEntityData extends i0.DataClass
|
|||
if (!nullToAbsent || stackId != null) {
|
||||
map['stack_id'] = i0.Variable<String>(stackId);
|
||||
}
|
||||
if (!nullToAbsent || libraryId != null) {
|
||||
map['library_id'] = i0.Variable<String>(libraryId);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
|
|
@ -1166,6 +1212,7 @@ class RemoteAssetEntityData extends i0.DataClass
|
|||
serializer.fromJson<int>(json['visibility']),
|
||||
),
|
||||
stackId: serializer.fromJson<String?>(json['stackId']),
|
||||
libraryId: serializer.fromJson<String?>(json['libraryId']),
|
||||
);
|
||||
}
|
||||
@override
|
||||
|
|
@ -1193,6 +1240,7 @@ class RemoteAssetEntityData extends i0.DataClass
|
|||
i1.$RemoteAssetEntityTable.$convertervisibility.toJson(visibility),
|
||||
),
|
||||
'stackId': serializer.toJson<String?>(stackId),
|
||||
'libraryId': serializer.toJson<String?>(libraryId),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -1214,6 +1262,7 @@ class RemoteAssetEntityData extends i0.DataClass
|
|||
i0.Value<String?> livePhotoVideoId = const i0.Value.absent(),
|
||||
i2.AssetVisibility? visibility,
|
||||
i0.Value<String?> stackId = const i0.Value.absent(),
|
||||
i0.Value<String?> libraryId = const i0.Value.absent(),
|
||||
}) => i1.RemoteAssetEntityData(
|
||||
name: name ?? this.name,
|
||||
type: type ?? this.type,
|
||||
|
|
@ -1238,6 +1287,7 @@ class RemoteAssetEntityData extends i0.DataClass
|
|||
: this.livePhotoVideoId,
|
||||
visibility: visibility ?? this.visibility,
|
||||
stackId: stackId.present ? stackId.value : this.stackId,
|
||||
libraryId: libraryId.present ? libraryId.value : this.libraryId,
|
||||
);
|
||||
RemoteAssetEntityData copyWithCompanion(i1.RemoteAssetEntityCompanion data) {
|
||||
return RemoteAssetEntityData(
|
||||
|
|
@ -1268,6 +1318,7 @@ class RemoteAssetEntityData extends i0.DataClass
|
|||
? data.visibility.value
|
||||
: this.visibility,
|
||||
stackId: data.stackId.present ? data.stackId.value : this.stackId,
|
||||
libraryId: data.libraryId.present ? data.libraryId.value : this.libraryId,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -1290,7 +1341,8 @@ class RemoteAssetEntityData extends i0.DataClass
|
|||
..write('deletedAt: $deletedAt, ')
|
||||
..write('livePhotoVideoId: $livePhotoVideoId, ')
|
||||
..write('visibility: $visibility, ')
|
||||
..write('stackId: $stackId')
|
||||
..write('stackId: $stackId, ')
|
||||
..write('libraryId: $libraryId')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
|
|
@ -1314,6 +1366,7 @@ class RemoteAssetEntityData extends i0.DataClass
|
|||
livePhotoVideoId,
|
||||
visibility,
|
||||
stackId,
|
||||
libraryId,
|
||||
);
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
|
|
@ -1335,7 +1388,8 @@ class RemoteAssetEntityData extends i0.DataClass
|
|||
other.deletedAt == this.deletedAt &&
|
||||
other.livePhotoVideoId == this.livePhotoVideoId &&
|
||||
other.visibility == this.visibility &&
|
||||
other.stackId == this.stackId);
|
||||
other.stackId == this.stackId &&
|
||||
other.libraryId == this.libraryId);
|
||||
}
|
||||
|
||||
class RemoteAssetEntityCompanion
|
||||
|
|
@ -1357,6 +1411,7 @@ class RemoteAssetEntityCompanion
|
|||
final i0.Value<String?> livePhotoVideoId;
|
||||
final i0.Value<i2.AssetVisibility> visibility;
|
||||
final i0.Value<String?> stackId;
|
||||
final i0.Value<String?> libraryId;
|
||||
const RemoteAssetEntityCompanion({
|
||||
this.name = const i0.Value.absent(),
|
||||
this.type = const i0.Value.absent(),
|
||||
|
|
@ -1375,6 +1430,7 @@ class RemoteAssetEntityCompanion
|
|||
this.livePhotoVideoId = const i0.Value.absent(),
|
||||
this.visibility = const i0.Value.absent(),
|
||||
this.stackId = const i0.Value.absent(),
|
||||
this.libraryId = const i0.Value.absent(),
|
||||
});
|
||||
RemoteAssetEntityCompanion.insert({
|
||||
required String name,
|
||||
|
|
@ -1394,6 +1450,7 @@ class RemoteAssetEntityCompanion
|
|||
this.livePhotoVideoId = const i0.Value.absent(),
|
||||
required i2.AssetVisibility visibility,
|
||||
this.stackId = const i0.Value.absent(),
|
||||
this.libraryId = const i0.Value.absent(),
|
||||
}) : name = i0.Value(name),
|
||||
type = i0.Value(type),
|
||||
id = i0.Value(id),
|
||||
|
|
@ -1418,6 +1475,7 @@ class RemoteAssetEntityCompanion
|
|||
i0.Expression<String>? livePhotoVideoId,
|
||||
i0.Expression<int>? visibility,
|
||||
i0.Expression<String>? stackId,
|
||||
i0.Expression<String>? libraryId,
|
||||
}) {
|
||||
return i0.RawValuesInsertable({
|
||||
if (name != null) 'name': name,
|
||||
|
|
@ -1437,6 +1495,7 @@ class RemoteAssetEntityCompanion
|
|||
if (livePhotoVideoId != null) 'live_photo_video_id': livePhotoVideoId,
|
||||
if (visibility != null) 'visibility': visibility,
|
||||
if (stackId != null) 'stack_id': stackId,
|
||||
if (libraryId != null) 'library_id': libraryId,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -1458,6 +1517,7 @@ class RemoteAssetEntityCompanion
|
|||
i0.Value<String?>? livePhotoVideoId,
|
||||
i0.Value<i2.AssetVisibility>? visibility,
|
||||
i0.Value<String?>? stackId,
|
||||
i0.Value<String?>? libraryId,
|
||||
}) {
|
||||
return i1.RemoteAssetEntityCompanion(
|
||||
name: name ?? this.name,
|
||||
|
|
@ -1477,6 +1537,7 @@ class RemoteAssetEntityCompanion
|
|||
livePhotoVideoId: livePhotoVideoId ?? this.livePhotoVideoId,
|
||||
visibility: visibility ?? this.visibility,
|
||||
stackId: stackId ?? this.stackId,
|
||||
libraryId: libraryId ?? this.libraryId,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -1538,6 +1599,9 @@ class RemoteAssetEntityCompanion
|
|||
if (stackId.present) {
|
||||
map['stack_id'] = i0.Variable<String>(stackId.value);
|
||||
}
|
||||
if (libraryId.present) {
|
||||
map['library_id'] = i0.Variable<String>(libraryId.value);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
|
|
@ -1560,12 +1624,21 @@ class RemoteAssetEntityCompanion
|
|||
..write('deletedAt: $deletedAt, ')
|
||||
..write('livePhotoVideoId: $livePhotoVideoId, ')
|
||||
..write('visibility: $visibility, ')
|
||||
..write('stackId: $stackId')
|
||||
..write('stackId: $stackId, ')
|
||||
..write('libraryId: $libraryId')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
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)',
|
||||
);
|
||||
i0.Index get idxRemoteAssetChecksum => i0.Index(
|
||||
'idx_remote_asset_checksum',
|
||||
'CREATE INDEX idx_remote_asset_checksum ON remote_asset_entity (checksum)',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue