From 4b9a726cdf4e49d301136e99d16cef083ec0f94e Mon Sep 17 00:00:00 2001 From: matt Date: Thu, 21 Apr 2022 13:11:18 +0000 Subject: [PATCH] Fix bug when reinstalling the database where sessions table doesn't exist yet --- utility/db/cleanDb.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/utility/db/cleanDb.js b/utility/db/cleanDb.js index e2966d2..1c8dc52 100644 --- a/utility/db/cleanDb.js +++ b/utility/db/cleanDb.js @@ -26,9 +26,15 @@ async function cleanDb() { const tables = Object.keys(data).reverse(); tables.push('sessions'); - for (const table of tables) - /* eslint-disable-next-line no-await-in-loop */ - await conn.runQuery(`DELETE FROM ${table};`); + for (const table of tables) { + try { + /* eslint-disable-next-line no-await-in-loop */ + await conn.runQuery(`DELETE FROM ${table};`); + } catch (e) { + if (table !== 'sessions') + throw e; + } + } conn.close(); }