How to update a column with sequelize migration
1 min read

How to update a column with sequelize migration

Using sequelize-cli migration:generate, we can update a column in a database model from a UUID to a String.


module.exports = {
  up: (queryInterface, Sequelize) => {
    return queryInterface.changeColumn('resources', 'resourceId',
      {
        type: Sequelize.STRING
      }
    )
  },

  down: (queryInterface, Sequelize) => {
    return queryInterface.changeColumn('resources', 'resourceId',
      {
        type: Sequelize.UUID
      }
    )
  }
}