Skip to content

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

Open
@sundeepgupta

Description

@sundeepgupta

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions