From 0d1bb496d55e136f64ab00160c2235ade868f342 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 22 Jan 2022 08:01:51 +0100 Subject: [PATCH] removed console and have better comments --- .../migrations/0012-login_user_backups_unify_wordlist.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/database/migrations/0012-login_user_backups_unify_wordlist.ts b/database/migrations/0012-login_user_backups_unify_wordlist.ts index a0bc0e744..a59a8da7f 100644 --- a/database/migrations/0012-login_user_backups_unify_wordlist.ts +++ b/database/migrations/0012-login_user_backups_unify_wordlist.ts @@ -1,7 +1,8 @@ /* MIGRATION TO CLEAN PRODUCTION DATA * * the way the passphrases are stored in login_user_backups is inconsistent. - * we need to try to detect which word list was used and transform it accordingly + * we need to detect which word list was used and transform it accordingly. + * This also removes the trailing space */ import fs from 'fs' @@ -46,9 +47,8 @@ const detectMnemonic = (passphrase: string[]): string[] => { } export async function upgrade(queryFn: (query: string, values?: any[]) => Promise>) { + // Loop through all user backups and update passphrase and mnemonic type if needed const userBackups = await queryFn(`SELECT * FROM login_user_backups`) - let i = 0 - // eslint-disable-next-line no-console userBackups.forEach(async (userBackup) => { const passphrase = userBackup.passphrase.split(' ') const newPassphrase = detectMnemonic(passphrase).join(' ') @@ -57,9 +57,6 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis `UPDATE login_user_backups SET passphrase = ?, mnemonic_type = ? WHERE id = ?`, [newPassphrase, TARGET_MNEMONIC_TYPE, userBackup.id], ) - i++ - // eslint-disable-next-line no-console - console.log(`Updated passphrase of user ${userBackup.user_id}`) } }) }