From 996202a6bd656e4dbb8590c320efc9653fdfb6c8 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 24 Aug 2021 17:56:29 +0200 Subject: [PATCH] if the old migration table is present selecting `fileName` will result in an SQL error --- backend/src/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/src/index.ts b/backend/src/index.ts index 981731c67..6e51ed2f4 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -22,9 +22,10 @@ const DB_VERSION = '0001-init_db' async function main() { // check for correct database version const con = await connection() - const [rows] = await con.query(`SELECT fileName FROM migrations ORDER BY version DESC LIMIT 1;`) + const [rows] = await con.query(`SELECT * FROM migrations ORDER BY version DESC LIMIT 1;`) if ( (rows).length === 0 || + !(rows)[0].fileName || (rows)[0].fileName.indexOf(DB_VERSION) === -1 ) { throw new Error(`Wrong database version - the backend requires '${DB_VERSION}'`)