1
0
mirror of https://github.com/immich-app/immich.git synced 2024-12-21 01:39:59 +02:00
immich/mobile/lib/utils/migration.dart
shenlong a233e176e5
fix(mobile): handle readonly and offline assets (#5565)
* feat: add isReadOnly and isOffline fields to Asset collection

* refactor: move asset iterable filters to extension

* hide asset actions based on offline and readOnly fields

* pr changes

* chore: doc comments

---------

Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
2024-01-05 21:02:16 -06:00

25 lines
603 B
Dart

import 'dart:async';
import 'package:immich_mobile/shared/models/store.dart';
import 'package:immich_mobile/utils/db.dart';
import 'package:isar/isar.dart';
Future<void> migrateDatabaseIfNeeded(Isar db) async {
final int version = Store.get(StoreKey.version, 1);
switch (version) {
case 1:
await _migrateTo(db, 2);
case 2:
await _migrateTo(db, 3);
case 3:
await _migrateTo(db, 4);
case 4:
await _migrateTo(db, 5);
}
}
Future<void> _migrateTo(Isar db, int version) async {
await clearAssetsAndAlbums(db);
await Store.put(StoreKey.version, version);
}