refactor: umzug

allow umzug v3 to work with the umzug v2 migrations

Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
Philip Molares
2026-08-21 20:23:17 +02:00
committed by Philip Molares
parent dcdf30b4c4
commit 788676aba4

View File

@@ -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 () {