mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
also check if migration table is present at all
This commit is contained in:
parent
ffc83845e5
commit
d4b5872ef2
@ -26,13 +26,16 @@ 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 COLUMNS FROM \`${CONFIG.DB_DATABASE}\`.\`migrations\` LIKE 'db_version';`,
|
||||
)
|
||||
const [rows] = await con.query(`SHOW TABLES FROM \`${CONFIG.DB_DATABASE}\` LIKE 'migrations';`)
|
||||
if ((<RowDataPacket>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 ((<RowDataPacket>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()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user