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}`);