import * as path from 'path'
-import { readdirPromise } from '../helpers/core-utils'
import { logger } from '../helpers/logger'
import { LAST_MIGRATION_VERSION } from './constants'
import { sequelizeTypescript } from './database'
+import { readdir } from 'fs-extra'
async function migrate () {
const tables = await sequelizeTypescript.getQueryInterface().showAllTables()
// The installer will do that
if (tables.length === 0) return
- let actualVersion: number = null
+ let actualVersion: number | null = null
const [ rows ] = await sequelizeTypescript.query('SELECT "migrationVersion" FROM "application"')
if (rows && rows[0] && rows[0].migrationVersion) {
try {
await executeMigration(actualVersion, migrationScript)
} catch (err) {
- logger.error('Cannot execute migration %s.', migrationScript.version, err)
+ logger.error('Cannot execute migration %s.', migrationScript.version, { err })
process.exit(-1)
}
}
// ---------------------------------------------------------------------------
async function getMigrationScripts () {
- const files = await readdirPromise(path.join(__dirname, 'migrations'))
+ const files = await readdir(path.join(__dirname, 'migrations'))
const filesToMigrate: {
version: string,
script: string