mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
feat(db): add local_trashed_asset table and integrate with restoration flow
- 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`
This commit is contained in:
parent
57540f6259
commit
020dfa7818
15 changed files with 8285 additions and 31 deletions
|
|
@ -0,0 +1,25 @@
|
|||
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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue