Are Sequelize migrations supposed to keep your model files in line with your database?
I used the sequelize cli to bootstrap a simple project and create a model node_modules/.bin/sequelize model:generate --name User --attributes email:string
. I migrated this with no issue.
Then I created the following migration file to add a notNull constraint to the user email attribute.
updateEmail migration
const models = require("../models")
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.changeColumn(models.User.tableName, 'email',{
type: Sequelize.STRING,
allowNull: false,
});
},
down: (queryInterface, Sequelize) => {
return queryInterface.changeColumn(models.User.tableName, 'email',{
type: Sequelize.STRING,
});
},
};
The database schema updated to add the constraint but the model file did not. Is there a way to automatically update the model files as you make migrations?