You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
.description("run all pending database migrations")
.option("-f --file <file>","use a custom config file")
.action(options=>{
global.options=options;
migrateMongo.database
.connect()
.then(db=>migrateMongo.up(db))
.then(migrated=>{
printMigrated(migrated);
process.exit(0);
})
.catch(err=>{
printMigrated(err.migrated);
handleError(err);
});
});
But if err.migrated is undefined, then a new error is thrown before the original error can be logged:
TypeError: Cannot read property 'forEach' of undefined
at printMigrated (node_modules/migrate-mongo/bin/migrate-mongo.js:12:12)
at database.connect.then.then.catch.err (node_modules/migrate-mongo/bin/migrate-mongo.js:74:9)
at process._tickCallback (internal/process/next_tick.js:68:7)
Unfortunately, some errors are thrown that don't have the migrated property, so it's difficult to get visibility into them.
To Reproduce
write a migration that throws an error when required
// requiring this file will error due to using await inside non-async fnmodule.exports={up(db){awaitsomePromise}down(db){}};
use migrate-mongo up
Other
Also if inserting the migration to the db collection fails, then you'll get an invalid error there as well:
Describe the bug
The error handler for
up
tries to log the migrations that couldn't be run. This is done in/bin/migrate-mongo
on L72.migrate-mongo/bin/migrate-mongo.js
Lines 58 to 75 in a610b9e
But if
err.migrated
is undefined, then a new error is thrown before the original error can be logged:Unfortunately, some errors are thrown that don't have the
migrated
property, so it's difficult to get visibility into them.To Reproduce
migrate-mongo up
Other
Also if inserting the migration to the db collection fails, then you'll get an invalid error there as well:
migrate-mongo/lib/actions/up.js
Lines 35 to 39 in a610b9e
The text was updated successfully, but these errors were encountered: