also check if migration table is present at all

This commit is contained in:
Ulf Gebhardt 2021-08-23 00:39:49 +02:00
parent ffc83845e5
commit d4b5872ef2
No known key found for this signature in database
GPG Key ID: 81308EFE29ABFEBD

View File

@ -26,6 +26,8 @@ export default async (): Promise<void> => {
DEFAULT COLLATE utf8mb4_unicode_ci;`)
// Check if old migration table is present, delete if needed
const [rows] = await con.query(`SHOW TABLES FROM \`${CONFIG.DB_DATABASE}\` LIKE 'migrations';`)
if ((<RowDataPacket>rows).length > 0) {
const [rows] = await con.query(
`SHOW COLUMNS FROM \`${CONFIG.DB_DATABASE}\`.\`migrations\` LIKE 'db_version';`,
)
@ -34,6 +36,7 @@ export default async (): Promise<void> => {
// eslint-disable-next-line no-console
console.log('Found and dropped old migrations table')
}
}
await con.end()
}