I am facing an issue while trying to incorporate my existing code into a migration script using Umzug in the context of Sequelize within a NestJS project.
Here is my current Umzug configuration:
require('ts-node/register')
const umzug = new Umzug({
migrations: {
path: process.env.MIGRATIONS_PATH,
pattern: /\.ts$/,
},
storage: 'sequelize',
storageOptions: {
sequelize: sequelize,
}
});
await sequelize.sync().then(() => umzug.up())
The skeleton for the migration script looks like this:
import PostTypeId from "data/PostTypeId";
export async function up() {
}
export async function down() {
}
Upon running Umzug during app startup, I encounter the following error:
[Nest] 316 - 02/21/2021, 11:24:42 AM [ExceptionHandler] Cannot find module 'data/PostTypeId'
Require stack:
- /home/node/app/backend/src/database/migrations/2021-02-17_22-11-00_game-data.ts
...
Error: Cannot find module 'data/PostTypeId'
Require stack:
...
The error clearly indicates that the required module cannot be imported. What would be the correct approach to import modules in an Umzug migration? While passing parameters could be an option, it may not suffice for varying requirements in different migrations.