mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
fixed bug where the migrations table was deleted every time
This commit is contained in:
parent
e8d6e871c4
commit
f1ed748983
@ -6,7 +6,7 @@
|
||||
* creating, deleting, renaming Databases.
|
||||
*/
|
||||
|
||||
import { createConnection } from 'mysql2/promise'
|
||||
import { createConnection, RowDataPacket } from 'mysql2/promise'
|
||||
import CONFIG from './config'
|
||||
|
||||
export default async (): Promise<void> => {
|
||||
@ -26,10 +26,10 @@ export default async (): Promise<void> => {
|
||||
DEFAULT COLLATE utf8mb4_unicode_ci;`)
|
||||
|
||||
// Check if old migration table is present, delete if needed
|
||||
const result = await con.query(
|
||||
const [rows] = await con.query(
|
||||
`SHOW COLUMNS FROM \`${CONFIG.DB_DATABASE}\`.\`migrations\` LIKE 'db_version';`,
|
||||
)
|
||||
if (result.length > 0) {
|
||||
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')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user