db-migrate / node-db-migrate

Database migration framework for node
Other
2.32k stars 360 forks source link

Problem with migration down using plugin #793

Closed maherma-adg closed 2 years ago

maherma-adg commented 2 years ago

I'm submitting a...

Current behavior

I developed a plugin db-migrate-plugin-es6cjs to enable use of db-migrate on ESM projects looking for '.cjs' files instead of '.js', basically I clone the typescript & coffee plugin versions. All work like a charm when migrate up, files are detected and executed without problems. Error happens on migrate down, I got a "[ERROR] Error: Cannot find module /........./migrationName". Tracing error show a try to import migration script with require function from a synthetic path without extension, as require function use ".js" by default, it can't find the module.

Expected behavior

Migration down must find the file the same way as migration up does.

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Enable the full potential of plugin mechanism.

I see two possible solutions:

Environment


db-migrate version: 0.11.13 & 1.0.0-beta.8
plugins with versions: db-migrate-plugin-es6cjs@0.0.1
db-migrate driver with versions: db-migrate-pg@1.2.2

Additional information:
- Node version: v16.15.1
- Platform:  Mac

Others:

wzrdtales commented 2 years ago

please use the search before opening a ticket: https://github.com/db-migrate/node-db-migrate/issues/784