Categories
JavaScript Answers

How to auto generate migrations with Node.js Sequelize CLI from Sequelize models?

Spread the love

To auto generate migrations with Node.js Sequelize CLI from Sequelize models, we run sequelize model:create.

For instance, we run

sequelize model:create --name MyUser --attributes first_name:string,last_name:string,bio:text

to create the MyUser model with the first_name, last_name, and bio fields.

Then a migration file will be created along with the model file.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *