title: Sequelize CLI how to create migrations from models?
body: <p>I have two models with relations one to many.</p>
  
  <p>I don't understand how to create migration files. Does each model have its own migration file or one migration file can create several tables from models and relations between them (for example as in rails migrations)?</p>
  
  <p>I had a look at many examples including Sequelize docs, and there are primitive examples of models creating and its migration.</p>
  
  <pre><code>//User model
  module.exports = function (sequelize, Sequelize) {
      var User = sequelize.define('users', {
          id: {
              type: Sequelize.INTEGER,
              primaryKey: true,
              autoIncrement: true,
          },
          email: {
              type: Sequelize.STRING,
              allowNull: false,
              unique: true,
          },
          password: {
              type: Sequelize.STRING,
              allowNull: false,
          },
      });
  
      return User;
  }
  
  //Order model
  module.exports = function (sequelize, Sequelize) {
      var Order = sequelize.define('orders', {
          id: {
              type: Sequelize.INTEGER,
              primaryKey: true,
              autoIncrement: true,
          },
          price: {
              type: Sequelize.INTEGER,
              allowNull: false,
          },
          totalPrice: {
              type: Sequelize.INTEGER,
              allowNull: false,
          },
      });
  
      return Order;
  }
  
  //db.js
  //Relations
  db.orders.belongsTo(db.users);
  db.users.hasMany(db.orders);
  </code></pre>
  
  <hr>
  
  <p>Addition</p>
  
  <p>I create migration for two models:</p>
  
  <pre><code>module.exports = {
      up: function (queryInterface, Sequelize, done) {
          return [
          queryInterface.createTable('users', {
              id: {
                  type: Sequelize.INTEGER,
                  primaryKey: true,
                  autoIncrement: true,
              },
              email: {
                  type: Sequelize.STRING,
                  allowNull: false,
                  unique: true,
              },
              password: {
                  type: Sequelize.STRING,
                  allowNull: false,
              },
          }),
          queryInterface.createTable('orders', {
              id: {
                  type: Sequelize.INTEGER,
                  primaryKey: true,
                  autoIncrement: true,
              },
              price: {
                  type: Sequelize.INTEGER,
                  allowNull: false,
              },
              totalPrice: {
                  type: Sequelize.INTEGER,
                  allowNull: false,
              },
              userId: {
                  type: Sequelize.INTEGER,
                  references: {
                      model: 'users',
                      key: 'id'
                  },
                  onUpdate: 'CASCADE',
                  onDelete: 'CASCADE'
              }
          }),
          done()
          ]
      },
  
      down: function (queryInterface, Sequelize, done) {
          return [
          queryInterface.dropTable('users'),
          queryInterface.dropTable('orders'),
          done()
          ]
      }
  };
  </code></pre>
  
  <p>Do I need to add into my migration file class methods for my models?</p>
  
  <pre><code>//for Order
  classMethods: {
      associate: function(models) {
          Model.belongsTo(models.users, (as: 'users'));
      }
  }
  
  //for User
  classMethods: {
      associate: function(models) {
          Model.hasMany(models.orders, (as: 'orders'));
      }
  }
  </code></pre>
  
  <p>//Addition 2</p>
  
  <p><a href="https://i.stack.imgur.com/0EBV3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0EBV3.png" alt="enter image description here"></a></p>