Delete outdated metadata after committing updated ones

In case the outdated metadata get successfully deleted and the updated metadata fail to commit, metadata gets lost, due to not being able to apply the migrations again since the outdated metadata have already been deleted
This commit is contained in:
schroda
2025-01-11 03:17:49 +01:00
parent 338fb96de3
commit 6c8df33a13

View File

@@ -309,12 +309,9 @@ const commitMigratedMetadata = (
commitedMigrations.add(itemMigrationKey);
try {
await updateMetadata([...metadataToUpdate], undefined, true);
await deleteMetadata(metadataKeysToDelete, undefined, true);
await updateMetadata(
[...metadataToUpdate, [getMetadataKey('migration') as AppMetadataKeys, METADATA_MIGRATIONS.length]],
undefined,
true,
);
await updateMetadata([['migration', METADATA_MIGRATIONS.length]]);
} catch (e) {
commitedMigrations.delete(itemMigrationKey);