From 5d111df401eb313b4099b5cbc33103c2ecf74556 Mon Sep 17 00:00:00 2001 From: sudoer777 <78781902+sudoer777@users.noreply.github.com> Date: Tue, 7 Dec 2021 10:32:59 -0700 Subject: [PATCH] Fix bug where database migrations wouldn't occur --- database/database.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/database/database.js b/database/database.js index 08c1a37..c0b7257 100644 --- a/database/database.js +++ b/database/database.js @@ -40,7 +40,7 @@ async function checkForDatabaseInitialization() { let latestMigration; try { const latestMigrationQuery = `SELECT value FROM metadata WHERE property = 'latest_migration';`; - latestMigration = (await executeQuery(latestMigrationQuery))[0][0]; + latestMigration = +((await executeQuery(latestMigrationQuery))[0][0]); } catch { latestMigration = 0; } @@ -54,7 +54,7 @@ async function performMigrations(currentMigration) { const migrationFileList = fs.readdirSync('database/migrations'); const latestMigration = +migrationFileList[migrationFileList.length - 1].slice(0, 1); - for(let i = currentMigration + 1; i <= latestMigration; i++) { + for(let i = +currentMigration + 1; i <= latestMigration; i++) { const sql = fs.readFileSync(`database/migrations/${i}.sql`).toString(); await executeQuery(sql); console.log(`Performed database migration ${i}`);