trashed_local_asset table mirror of local_asset table structure

trashed_local_asset<->local_asset transfer data on move to trash or restore
refactor code
This commit is contained in:
Peter Ombodi 2025-09-24 16:58:56 +03:00
parent b15056deb9
commit bec1b30554
19 changed files with 1191 additions and 620 deletions

View file

@ -1,42 +1,39 @@
import 'package:drift/drift.dart';
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
import 'package:immich_mobile/domain/models/asset/trashed_asset.model.dart';
import 'package:immich_mobile/infrastructure/entities/trashed_local_asset.entity.drift.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_trashed_local_asset_checksum ON trashed_local_asset_entity (checksum)')
class TrashedLocalAssetEntity extends Table with DriftDefaultsMixin {
class TrashedLocalAssetEntity extends Table with DriftDefaultsMixin, AssetEntityMixin {
const TrashedLocalAssetEntity();
TextColumn get id => text()();
TextColumn get albumId => text()();
TextColumn get volume => text().nullable()();
TextColumn get checksum => text().nullable()();
TextColumn get name => text()();
BoolColumn get isFavorite => boolean().withDefault(const Constant(false))();
IntColumn get type => intEnum<AssetType>()();
DateTimeColumn get createdAt => dateTime().withDefault(currentDateAndTime)();
DateTimeColumn get updatedAt => dateTime().withDefault(currentDateAndTime)();
IntColumn get size => integer().nullable()();
IntColumn get orientation => integer().withDefault(const Constant(0))();
@override
Set<Column> get primaryKey => {id};
Set<Column> get primaryKey => {id, albumId};
}
extension TrashedLocalAssetEntityDataDomainExtension on TrashedLocalAssetEntityData {
TrashedAsset toDto(String albumId) => TrashedAsset(
TrashedAsset toDto() => TrashedAsset(
id: id,
name: name,
volume: volume,
albumId: albumId,
checksum: checksum,
type: type,
createdAt: createdAt,
updatedAt: updatedAt,
size: size,
);
}