diff --git a/mobile/lib/utils/migration.dart b/mobile/lib/utils/migration.dart index 52c2fc2306..b20950c089 100644 --- a/mobile/lib/utils/migration.dart +++ b/mobile/lib/utils/migration.dart @@ -166,25 +166,33 @@ Future _migrateDeviceAsset(Isar db) async { } Future _migrateDeviceAssetToSqlite(Isar db, Drift drift) async { - final isarDeviceAssets = - await db.deviceAssetEntitys.where().sortByAssetId().findAll(); - await drift.batch((batch) { - for (final deviceAsset in isarDeviceAssets) { - final companion = LocalAssetEntityCompanion( - updatedAt: Value(deviceAsset.modifiedTime), - id: Value(deviceAsset.assetId), - checksum: Value(base64.encode(deviceAsset.hash)), - ); - batch.insert<$LocalAssetEntityTable, LocalAssetEntityData>( - drift.localAssetEntity, - companion, - onConflict: DoUpdate( - (_) => companion, - where: (old) => old.updatedAt.equals(deviceAsset.modifiedTime), - ), + try { + final isarDeviceAssets = + await db.deviceAssetEntitys.where().sortByAssetId().findAll(); + await drift.batch((batch) { + for (final deviceAsset in isarDeviceAssets) { + final companion = LocalAssetEntityCompanion( + updatedAt: Value(deviceAsset.modifiedTime), + id: Value(deviceAsset.assetId), + checksum: Value(base64.encode(deviceAsset.hash)), + ); + batch.insert<$LocalAssetEntityTable, LocalAssetEntityData>( + drift.localAssetEntity, + companion, + onConflict: DoUpdate( + (_) => companion, + where: (old) => old.updatedAt.equals(deviceAsset.modifiedTime), + ), + ); + } + }); + } catch (error) { + if (kDebugMode) { + debugPrint( + "[MIGRATION] Error while migrating device assets to SQLite: $error", ); } - }); + } } class _DeviceAsset {