sequelize update index column code example

Example: sequelize update index column

'use strict';

module.exports = {
  up: (queryInterface, Sequelize) => {
    return queryInterface.addIndex('reports', ['client_id'])
      .then(() => {
        return queryInterface.addIndex('reports', ['report_name'])
      })
      .then(() => {
        return queryInterface.addIndex('reports', ['report_date'])
      })
  },

  down: (queryInterface, Sequelize) => {
    return queryInterface.removeIndex('reports', ['client_id'])
    .then(() => {
      return queryInterface.removeIndex('reports', ['report_name'])
    })
    .then(() => {
      return queryInterface.removeIndex('reports', ['report_date'])
    })
  }
};

Tags:

Misc Example