sequelize / umzug

Framework agnostic migration tool for Node.js
MIT License
1.98k stars 158 forks source link

mjs extension support #626

Closed mysuf closed 8 months ago

mysuf commented 8 months ago

I decided to go mjs way instead of type: module, but umzug can't handle these files atm.

require doesn't work with esm so then maybe it would be nice to make resolver async so I can handle these files with dynamic import.

Now I made it work like this:

        resolve: ({ name, path, context }) => {
            return {
                // adjust the parameters Umzug will
                // pass to migration methods when called
                name,
                up: async () => {
                    const { up } = await import(path);
                    return up({ context });
                },
                down: async () => {
                    const { down } = await import(path);
                    return down({ context });
                },
            };
        },

Thanks

mmkal commented 8 months ago

Closing in favour of #608