umzug: migration return array failed to execute

error details

== 20180828102922-add-sponsor-intro-to-lotteries: migrating =======

ERROR: Error: Migration 20180828102922-add-sponsor-intro-to-lotteries.js (or wrapper) didn't return a promise
    at /Users/greatghoul/Workspace/Miidii/Sweetfoot/node_modules/umzug/lib/migration.js:132:15
    at Generator.next (<anonymous>)
    at step (/Users/greatghoul/Workspace/Miidii/Sweetfoot/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
    at /Users/greatghoul/Workspace/Miidii/Sweetfoot/node_modules/babel-runtime/helpers/asyncToGenerator.js:28:13
    at process._tickCallback (internal/process/next_tick.js:68:7)

migration file

'use strict';

module.exports = {
  up: (queryInterface, Sequelize) => {
    return [
      queryInterface.addColumn('Lotteries', 'sponsor_intro', {
        type: Sequelize.TEXT,
        allowNull: true,
      }),
      queryInterface.addColumn('Lotteries', 'prefs', {
        type: Sequelize.JSONB,
        allowNull: false,
        defaultValue: {},
      }),
      queryInterface.addColumn('Lotteries', 'award_usage', {
        type: Sequelize.TEXT,
        allowNull: true,
      }),
      queryInterface.addColumn('Lotteries', 'award_price', {
        type: Sequelize.STRING,
        allowNull: true,
      }),
    ];
  },

  down: (queryInterface, Sequelize) => {
    return [
      queryInterface.removeColumn('Lotteries', 'sponsor_intro'),
      queryInterface.removeColumn('Lotteries', 'prefs'),
      queryInterface.removeColumn('Lotteries', 'award_usage'),
      queryInterface.removeColumn('Lotteries', 'award_price'),
    ];
  }
};

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 4
  • Comments: 16 (1 by maintainers)

Commits related to this issue

Most upvoted comments

Was an easy fix for me to just change return [ to return Promise.all([ and ending ]) Should probably have been a Major semver update as it’s a breaking change?

I vote for the array support.

@thutv18 You could easily fix your migration by wrapping it in a Promise.all Eg return Promise.all([ queryInterface.addColumn ... ])

After reinstalling version sequelize 4.36.1 & sequelize-cli 4.0.0 then running migrations locally I came across this issue. It would be useful to know whether there is a way to revert back to how it was before this change was implemented. Are there any release notes on this?

Ran into this today as well…

Question is: do we wanna keep the array support or are we dropping it?

'use strict';

module.exports = {
  up: (queryInterface, Sequelize) => {
    return // <---- it returns here, code below this line not executed.
    queryInterface.addColumn('tablename', 'columnname1', Sequelize.BLOB)
      .then(() => {
        return queryInterface.addColumn('tablename', 'columnname2', Sequelize.STRING);
      })
  },

  down: (queryInterface, Sequelize) => {
    return
    queryInterface.removeColumn('tablename1', 'columnname1')
      .then(() => {
        return queryInterface.removeColumn('tablename1', 'columnname2');
      });
  }
}

@samathan you should change it to

'use strict';

module.exports = {
  up: (queryInterface, Sequelize) => {
    return queryInterface.addColumn('tablename', 'columnname1', Sequelize.BLOB)
      .then(() => {
        return queryInterface.addColumn('tablename', 'columnname2', Sequelize.STRING);
      })
  },

  down: (queryInterface, Sequelize) => {
    return queryInterface.removeColumn('tablename1', 'columnname1')
      .then(() => {
        return queryInterface.removeColumn('tablename1', 'columnname2');
      });
  }
}

I locked umzug to 2.1.0.

{
  "dependencies": {
    ...
    "umzug": "2.1.0",
    ...
  }
}

I guess it should be using Promise instead of Array.

return queryInterface.addColumn(...)
             .then(() => {
               return queryInterface.addColumn(...)
             })
             .then(...)