0

I've generated a model using node_modules/.bin/sequelize model:create --name Student --attributes firstName:string,email:string. Now I want to add a new column, major. I know you can manually create a migration like so:

module.exports = {
  up: function(queryInterface, Sequelize) {
    // logic for transforming into the new state
    return queryInterface.addColumn(
      'major',
      'compSci',
     Sequelize.BOOLEAN
    );

  },

  down: function(queryInterface, Sequelize) {
    // logic for reverting the changes
    return queryInterface.removeColumn(
      'major',
      'compSci'
    );
  }
}

Is it possible to edit the model, and have migrations be automatically created? So in student.js you'd add {major:{type:Sequelize.STRING}}, and then generate new migrations?

James L.
  • 12,893
  • 4
  • 49
  • 60

1 Answers1

0

Looks like Sequelize cannot auto-generate migrations source. I'll try TypeORM instead, whose github page says that it has automatic migrations.

James L.
  • 12,893
  • 4
  • 49
  • 60