seppevs / migrate-mongo

A database migration tool for MongoDB in Node
MIT License
931 stars 166 forks source link

Add possibility to perform custom code on certain events #297

Open timschlechter opened 3 years ago

timschlechter commented 3 years ago

Is your feature request related to a problem? Please describe. I would like to write logs when certain things happen, for example a migration script started, completed or failed.

Describe the solution you'd like Add handlers in the migratie-mongo-config which are used when these events happen. For example:

const config = {
  ...,
  onMigrationStarted: (filename) => { console.log(`Migration ${filename) started`); },
  onMigrationCompleted: (filename, err) => { 
    if (err) {
      console.log(`Migration ${filename) failed: ${err.message}`); },
    } else {
      console.log(`Migration ${filename) completed successfully`); },
    }    
};

Additional context Would you consider having something like this in this package? If so, I can prepare a PR where this is implemented. Feedback and/or alternative solutions are also very appreciated.

nhuray commented 3 years ago

pretty useful also because it allows to use the logging library of our choice