mirror of
https://github.com/immich-app/immich
synced 2025-10-17 18:19:27 +00:00
- Add new `local_trashed_asset` table to store metadata of trashed assets - Save trashed asset info into `local_trashed_asset` before deletion - Use `local_trashed_asset` as source for asset restoration - Implement file restoration by `mediaId`
25 lines
1 KiB
Dart
25 lines
1 KiB
Dart
import 'package:drift/drift.dart';
|
|
import 'package:immich_mobile/domain/models/local_trashed_asset.model.dart';
|
|
import 'package:immich_mobile/infrastructure/entities/local_trashed_asset.entity.drift.dart';
|
|
import 'package:immich_mobile/infrastructure/entities/remote_asset.entity.dart';
|
|
import 'package:immich_mobile/infrastructure/utils/drift_default.mixin.dart';
|
|
|
|
@TableIndex.sql(
|
|
'CREATE INDEX IF NOT EXISTS idx_local_trashed_asset_remote_id ON local_trashed_asset_entity (remote_id)',
|
|
)
|
|
class LocalTrashedAssetEntity extends Table with DriftDefaultsMixin {
|
|
const LocalTrashedAssetEntity();
|
|
|
|
TextColumn get id => text()();
|
|
|
|
TextColumn get remoteId => text().references(RemoteAssetEntity, #id, onDelete: KeyAction.cascade)();
|
|
|
|
DateTimeColumn get createdAt => dateTime().withDefault(currentDateAndTime)();
|
|
|
|
@override
|
|
Set<Column> get primaryKey => {id};
|
|
}
|
|
|
|
extension LocalTrashedAssetEntityDataDomainExtension on LocalTrashedAssetEntityData {
|
|
LocalTrashedAsset toDto() => LocalTrashedAsset(localId: id, remoteId: remoteId, createdAt: createdAt);
|
|
}
|