From 352404533bb45d48dada0d8b88c8f892bfbe4450 Mon Sep 17 00:00:00 2001 From: Vyacheslav Tumanov Date: Tue, 4 Jul 2023 06:51:17 +0500 Subject: [PATCH] add migration for icons with typo in it (#3478) Signed-off-by: Vyacheslav Tumanov --- models/tracker/src/migration.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/models/tracker/src/migration.ts b/models/tracker/src/migration.ts index 4927503f09..ff89fc19e3 100644 --- a/models/tracker/src/migration.ts +++ b/models/tracker/src/migration.ts @@ -76,10 +76,21 @@ async function createDefaults (tx: TxOperations): Promise { ) } +async function fixProjectIcons (tx: TxOperations): Promise { + // @ts-expect-error + const projectsWithWrongIcon = await tx.findAll(tracker.class.Project, { icon: 'tracker:component:IconWithEmojii' }) + const promises = [] + for (const project of projectsWithWrongIcon) { + promises.push(tx.update(project, { icon: tracker.component.IconWithEmoji })) + } + await Promise.all(promises) +} + export const trackerOperation: MigrateOperation = { async migrate (client: MigrationClient): Promise {}, async upgrade (client: MigrationUpgradeClient): Promise { const tx = new TxOperations(client, core.account.System) await createDefaults(tx) + await fixProjectIcons(tx) } }