2023-03-23 03:36:44 +02:00
|
|
|
import 'dart:async';
|
|
|
|
|
2023-02-09 19:32:08 +02:00
|
|
|
import 'package:immich_mobile/shared/models/store.dart';
|
2023-03-27 04:35:52 +02:00
|
|
|
import 'package:immich_mobile/utils/db.dart';
|
2023-03-18 16:55:11 +02:00
|
|
|
import 'package:isar/isar.dart';
|
2023-02-09 19:32:08 +02:00
|
|
|
|
2023-03-27 04:35:52 +02:00
|
|
|
Future<void> migrateDatabaseIfNeeded(Isar db) async {
|
|
|
|
final int version = Store.get(StoreKey.version, 1);
|
|
|
|
switch (version) {
|
|
|
|
case 1:
|
|
|
|
await _migrateV1ToV2(db);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> _migrateV1ToV2(Isar db) async {
|
|
|
|
await clearAssetsAndAlbums(db);
|
|
|
|
await Store.put(StoreKey.version, 2);
|
|
|
|
}
|