mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
fixed build js up/down/reset commands
started to do some more prepare stuff
This commit is contained in:
parent
9660a883c3
commit
d480cadf93
@ -10,9 +10,9 @@
|
||||
"scripts": {
|
||||
"build": "tsc --build",
|
||||
"clean": "tsc --build --clean",
|
||||
"up": "node build/src/index.js up",
|
||||
"down": "node build/src/index.js down",
|
||||
"reset": "node build/src/index.js reset",
|
||||
"up": "cd build && node src/index.js up",
|
||||
"down": "cd build && node src/index.js down",
|
||||
"reset": "cd build && node src/index.js reset",
|
||||
"dev_up": "nodemon -w ./ --ext ts --exec ts-node src/index.ts up",
|
||||
"dev_down": "nodemon -w ./ --ext ts --exec ts-node src/index.ts down",
|
||||
"dev_reset": "nodemon -w ./ --ext ts --exec ts-node src/index.ts reset",
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
import { createConnection } from 'mysql'
|
||||
import CONFIG from './config'
|
||||
|
||||
export default async () => {
|
||||
export default async (): Promise<void> => {
|
||||
const con = createConnection({
|
||||
host: CONFIG.DB_HOST,
|
||||
port: CONFIG.DB_PORT,
|
||||
@ -24,4 +24,19 @@ export default async () => {
|
||||
CREATE DATABASE IF NOT EXISTS ${CONFIG.DB_DATABASE}
|
||||
DEFAULT CHARACTER SET utf8mb4
|
||||
DEFAULT COLLATE utf8mb4_unicode_ci;`)
|
||||
|
||||
// Check if old migration table is present, delete if needed
|
||||
await con.query(
|
||||
`SHOW COLUMNS FROM \`${CONFIG.DB_DATABASE}\`.\`migrations\` LIKE 'version';`,
|
||||
(err, result /* , fields */) => {
|
||||
if (err) throw err
|
||||
if (result.length > 0) {
|
||||
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