config, contains config file, which tells CLI how to connect with database
models, contains all models for your project
migrations, contains all migration files
seeders, contains all seed files

1-创建模型
node_modules/.bin/sequelize model:generate --name User --attributes firstName:string,lastName:string,email:string
--在models目录下产生模型定义
--migrations folder下创建一个表创建文件
2、模型升级
---升级 node_modules/.bin/sequelize db:migrate
---降级 $ node_modules/.bin/sequelize db:migrate:undo
   You can use db:migrate:undo, this command will revert most recent migration.
---取消所有升级
 node_modules/.bin/sequelize db:migrate:undo:all --to XXXXXXXXXXXXXX-create-posts.js

 3、数据升级
    ---创建种子 node_modules/.bin/sequelize seed:generate --name demo-user
    Let's create a seed file which will add a demo user to our User table.
    This command will create a seed file in seeders folder. File name will look something like XXXXXXXXXXXXXX-demo-user.js. It follows the same up / down semantics as the migration files.

    Now we should edit this file to insert demo user to User table.

    'use strict';
    module.exports = {
      up: (queryInterface, Sequelize) => {
        return queryInterface.bulkInsert('Users', [{
            firstName: 'John',
            lastName: 'Doe',
            email: 'demo@demo.com'
          }], {});
      },

      down: (queryInterface, Sequelize) => {
        return queryInterface.bulkDelete('Users', null, {});
      }
    };
    ---运行种子 node_modules/.bin/sequelize db:seed:all
     n last step you have create a seed file. It's still not committed to database.
     To do that we need to run a simple command.
    ---取消种子 node_modules/.bin/sequelize db:seed:undo
       If you wish to undo most recent seed
    ---取消所有node_modules/.bin/sequelize db:seed:undo:all
       If you wish to undo all seeds
  升级示例
  'use strict';
   module.exports = {
     up: (queryInterface, Sequelize) => {

       console.log("MIGRATION UP");

       Sequelize.query(' \
             ALTER TABLE "personPartners" \
             DROP CONSTRAINT "personPartners_personId_fkey" \
       ').spread(console.log);

       Sequelize.query(' \
         ALTER TABLE "personPartners"  \
         ADD CONSTRAINT "personPartners_personId_fkey_v2" \
         FOREIGN KEY (id) \
         REFERENCES "people" \
         ON DELETE CASCADE \
         ON UPDATE CASCADE \
       ').spread(console.log);

     },
     down: (queryInterface, Sequelize) => {
       Sequelize.query(' \
             ALTER TABLE "personPartners" \
             DROP CONSTRAINT "personPartners_personId_fkey_v2" \
       ').spread(console.log);
       Sequelize.query(' \
         ALTER TABLE "personPartners" \
         ADD CONSTRAINT "personPartners_personId_fkey" \
         FOREIGN KEY (id) \
         REFERENCES "people" \
         ON DELETE CASCADE \
       ').spread(console.log)
   };
