2023-03-23 01:36:44 +00:00
|
|
|
import 'dart:async';
|
|
|
|
|
2024-05-01 02:36:40 +00:00
|
|
|
import 'package:immich_mobile/entities/store.entity.dart';
|
2023-03-27 02:35:52 +00:00
|
|
|
import 'package:immich_mobile/utils/db.dart';
|
2023-03-18 14:55:11 +00:00
|
|
|
import 'package:isar/isar.dart';
|
2023-02-09 17:32:08 +00:00
|
|
|
|
2024-12-16 16:11:48 +00:00
|
|
|
const int targetVersion = 8;
|
2024-05-14 15:35:37 +00:00
|
|
|
|
2023-03-27 02:35:52 +00:00
|
|
|
Future<void> migrateDatabaseIfNeeded(Isar db) async {
|
|
|
|
final int version = Store.get(StoreKey.version, 1);
|
2024-05-14 15:35:37 +00:00
|
|
|
if (version < targetVersion) {
|
|
|
|
_migrateTo(db, targetVersion);
|
2023-03-27 02:35:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-10 18:13:59 +00:00
|
|
|
Future<void> _migrateTo(Isar db, int version) async {
|
2023-03-27 02:35:52 +00:00
|
|
|
await clearAssetsAndAlbums(db);
|
2023-06-10 18:13:59 +00:00
|
|
|
await Store.put(StoreKey.version, version);
|
2023-03-27 02:35:52 +00:00
|
|
|
}
|