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.
|
* creating, deleting, renaming Databases.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { createConnection } from 'mysql2/promise'
|
import { createConnection, RowDataPacket } from 'mysql2/promise'
|
||||||
import CONFIG from './config'
|
import CONFIG from './config'
|
||||||
|
|
||||||
export default async (): Promise<void> => {
|
export default async (): Promise<void> => {
|
||||||
@ -26,10 +26,10 @@ export default async (): Promise<void> => {
|
|||||||
DEFAULT COLLATE utf8mb4_unicode_ci;`)
|
DEFAULT COLLATE utf8mb4_unicode_ci;`)
|
||||||
|
|
||||||
// Check if old migration table is present, delete if needed
|
// 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';`,
|
`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\``)
|
await con.query(`DROP TABLE \`${CONFIG.DB_DATABASE}\`.\`migrations\``)
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log('Found and dropped old migrations table')
|
console.log('Found and dropped old migrations table')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user