【问题标题】:Can we generate model from using a migration file via sequalize?我们可以通过 sequelize 使用迁移文件生成模型吗?
【发布时间】:2020-03-10 07:22:13
【问题描述】:

我们可以使用迁移文件生成模型吗?我已经创建了迁移文件。我想用它生成相应的模型文件吗?节点sequlizer有可能吗?

这是我的一个迁移文件:

module.exports = {
  up: (queryInterface, Sequelize) => {
    return queryInterface.createTable('Vendors', {
      id: {
        allowNull: false,
        primaryKey: true,
        type: Sequelize.UUID,
        defaultValue: Sequelize.UUIDV1
      },
      firstName: {
        type: Sequelize.STRING
      }
    });
  },
  down: (queryInterface, Sequelize) => {
    return queryInterface.dropTable('Vendors');
  }
}; ```

i know it is possible to generate migration using given model file . Can we do the opposite of that ?

【问题讨论】:

    标签: node.js migration sequelize.js sequelize-cli sequelize-auto


    【解决方案1】:

    只需像这样运行您创建的迁移:

    node ./node_modules/sequelize-auto-migrations/bin/runmigration
    

    同时运行db:migrate

    【讨论】:

      猜你喜欢
      • 2016-09-27
      • 2015-03-06
      • 2022-01-20
      • 2020-02-01
      • 2021-03-17
      • 1970-01-01
      • 2020-08-17
      • 2020-05-29
      • 2020-11-09
      相关资源
      最近更新 更多