diff --git a/lib/models/index.js b/lib/models/index.js index f4e51a17..4847b4c7 100644 --- a/lib/models/index.js +++ b/lib/models/index.js @@ -4,7 +4,7 @@ const fs = require('fs') const path = require('path') const Sequelize = require('sequelize') const { cloneDeep } = require('lodash') -const Umzug = require('umzug') +const { SequelizeStorage, Umzug } = require('umzug') // core const config = require('../config') @@ -66,21 +66,24 @@ Object.keys(db).forEach(function (modelName) { const umzug = new Umzug({ migrations: { - path: path.resolve(__dirname, '..', 'migrations'), - params: [ - sequelize.getQueryInterface(), - Sequelize.DataTypes - ] + glob: path.resolve(__dirname, '..', 'migrations', '*.js'), + resolve: ({ name, path, context }) => { + // Adjust the migration from the new signature to the v2 signature, making easier to upgrade to v3 + const migration = require(path) + return { + name, + up: async () => migration.up(context, Sequelize), + down: async () => migration.down(context, Sequelize) + } + } }, + context: sequelize.getQueryInterface(), // Required wrapper function required to prevent winstion issue // https://github.com/winstonjs/winston/issues/1577 logging: message => { logger.info(message) }, - storage: 'sequelize', - storageOptions: { - sequelize - } + storage: new SequelizeStorage({ sequelize }) }) db.runMigrations = async function runMigrations () {