I\'ve just started using Sequelize and Sequelize CLI
Since it\'s a development time, there are a frequent addition and deletion of columns. What the best the method
If you want to add multiple columns to the same table, wrap everything in a Promise.all()
and put the columns you'd like to add within an array:
module.exports = {
up: (queryInterface, Sequelize) => {
return Promise.all([
queryInterface.addColumn(
'tableName',
'columnName1',
{
type: Sequelize.STRING
}
),
queryInterface.addColumn(
'tableName',
'columnName2',
{
type: Sequelize.STRING
}
),
]);
},
down: (queryInterface, Sequelize) => {
return Promise.all([
queryInterface.removeColumn('tableName', 'columnName1'),
queryInterface.removeColumn('tableName', 'columnName2')
]);
}
};
You can have any column type supported by sequelize https://sequelize.readthedocs.io/en/2.0/api/datatypes/