fullcube / loopback-component-migrate

Migration framework for loopback
43 stars 30 forks source link

Callback not getting called (or promise not being returned) when there are no migrations to run #6

Open sundeepgupta opened 8 years ago

sundeepgupta commented 8 years ago

I'm implementing the migration in a boot script before my actual application code is run like this:

const loopback = require('loopback');
const Migration = loopback.getModel('Migration');

module.exports = app => {
  Migration.migrate('up', error => {
    if (error) {
      console.error('Error in migrations: %s', error.stack);
      return;
    }

    console.log('boot app now');
  });
};

This works when there are actual migrations pending. However, if not, I see "No new migrations to run." outputted, but the "boot app now" log line never gets executed.

If I put cb() here: https://github.com/fullcube/loopback-component-migrate/blob/master/lib/models/migration.js#L152, it works ok, but I'm pretty sure that's not correct, also, this wouldn't return a promise. I'm not sure how to fix this in the right way.

laktarugar commented 7 years ago

Find another way for fixing this issues

//life hack:(
Migration.on('complete', cb);
Migration.migrate('up', cb);
https://guides.github.com/features/mastering-markdown/