diff --git a/database/src/prepare.ts b/database/src/prepare.ts index 6fa723afd..440289aea 100644 --- a/database/src/prepare.ts +++ b/database/src/prepare.ts @@ -26,13 +26,16 @@ export default async (): Promise => { DEFAULT COLLATE utf8mb4_unicode_ci;`) // Check if old migration table is present, delete if needed - const [rows] = await con.query( - `SHOW COLUMNS FROM \`${CONFIG.DB_DATABASE}\`.\`migrations\` LIKE 'db_version';`, - ) + const [rows] = await con.query(`SHOW TABLES FROM \`${CONFIG.DB_DATABASE}\` LIKE 'migrations';`) if ((rows).length > 0) { - await con.query(`DROP TABLE \`${CONFIG.DB_DATABASE}\`.\`migrations\``) - // eslint-disable-next-line no-console - console.log('Found and dropped old migrations table') + const [rows] = await con.query( + `SHOW COLUMNS FROM \`${CONFIG.DB_DATABASE}\`.\`migrations\` LIKE 'db_version';`, + ) + if ((rows).length > 0) { + await con.query(`DROP TABLE \`${CONFIG.DB_DATABASE}\`.\`migrations\``) + // eslint-disable-next-line no-console + console.log('Found and dropped old migrations table') + } } await con.end()