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
}
)
}
}