feat: full local assets / album sync

This commit is contained in:
shenlong-tanwen
2024-10-17 23:33:00 +05:30
parent a09710ec7b
commit c91a2878dc
87 changed files with 2417 additions and 366 deletions
@@ -1,11 +1,21 @@
import 'package:drift/drift.dart';
import 'package:immich_mobile/domain/entities/asset.entity.dart';
class LocalAlbum extends Table {
const LocalAlbum();
class Album extends Table {
const Album();
IntColumn get id => integer().autoIncrement()();
TextColumn get localId => text().unique()();
TextColumn get name => text()();
DateTimeColumn get modifiedTime =>
dateTime().withDefault(currentDateAndTime)();
IntColumn get thumbnailAssetId => integer()
.references(Asset, #id, onDelete: KeyAction.setNull)
.nullable()();
// Local only
TextColumn get localId => text().nullable().unique()();
// Remote only
TextColumn get remoteId => text().nullable().unique()();
}
@@ -0,0 +1,16 @@
import 'package:drift/drift.dart';
import 'package:immich_mobile/domain/entities/album.entity.dart';
import 'package:immich_mobile/domain/entities/asset.entity.dart';
class AlbumToAsset extends Table {
const AlbumToAsset();
IntColumn get assetId =>
integer().references(Asset, #id, onDelete: KeyAction.cascade)();
IntColumn get albumId =>
integer().references(Album, #id, onDelete: KeyAction.cascade)();
@override
Set<Column> get primaryKey => {assetId, albumId};
}
@@ -0,0 +1,14 @@
import 'package:drift/drift.dart';
import 'package:immich_mobile/domain/entities/album.entity.dart';
class AlbumETag extends Table {
const AlbumETag();
IntColumn get id => integer().autoIncrement()();
IntColumn get albumId =>
integer().references(Album, #id, onDelete: KeyAction.cascade).unique()();
DateTimeColumn get modifiedTime =>
dateTime().withDefault(currentDateAndTime)();
IntColumn get assetCount => integer().withDefault(const Constant(0))();
}
@@ -0,0 +1,14 @@
import 'package:drift/drift.dart';
@TableIndex(name: 'deviceassethash_localId', columns: {#localId})
@TableIndex(name: 'deviceassethash_hash', columns: {#hash})
class DeviceAssetToHash extends Table {
const DeviceAssetToHash();
IntColumn get id => integer().autoIncrement()();
TextColumn get localId => text().unique()();
TextColumn get hash => text()();
DateTimeColumn get modifiedTime =>
dateTime().withDefault(currentDateAndTime)();
}