1
0
mirror of https://github.com/immich-app/immich.git synced 2025-07-16 07:24:40 +02:00

refactor(mobile): remove int user id (#16814)

* refactor: user entity

* chore: rebase fixes

* refactor: remove int user Id

* refactor: migrate store userId from int to string

* refactor: rename uid to id

* fix: migration

* pr feedback

---------

Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
shenlong
2025-03-18 21:35:37 +05:30
committed by GitHub
parent e96ffd43e7
commit 9cf3b88f80
38 changed files with 182 additions and 157 deletions

View File

@ -6,13 +6,33 @@ import 'package:immich_mobile/entities/asset.entity.dart';
import 'package:immich_mobile/entities/etag.entity.dart';
import 'package:immich_mobile/entities/store.entity.dart';
import 'package:immich_mobile/infrastructure/entities/exif.entity.dart';
import 'package:immich_mobile/infrastructure/entities/store.entity.dart';
import 'package:immich_mobile/infrastructure/entities/user.entity.dart';
import 'package:isar/isar.dart';
const int targetVersion = 8;
const int targetVersion = 9;
Future<void> migrateDatabaseIfNeeded(Isar db) async {
final int version = Store.get(StoreKey.version, 1);
if (version < 9) {
await Store.put(StoreKey.version, version);
final value = await db.storeValues.get(StoreKey.currentUser.id);
if (value != null) {
final id = value.intValue;
if (id == null) {
return;
}
await db.writeTxn(() async {
final user = await db.users.get(id);
await db.storeValues
.put(StoreValue(StoreKey.currentUser.id, strValue: user?.id));
});
}
// Do not clear other entities
return;
}
if (version < targetVersion) {
_migrateTo(db, targetVersion);
}