序列化:使用迁移脚本将列添加到多个表中

时间:2018-12-12 04:43:48

标签: javascript node.js sequelize.js sequelize-typescript

我正尝试通过片段迁移脚本向多个表添加单列isDeleted,如代码段所示。

module.exports = {
up: (queryInterface, Sequelize) => {
    queryInterface.addColumn(
      ['category', 'products', 'orders', 'purchases'],
      'isDeleted',
      {
        type: Sequelize.BOOLEAN,
      },
    )
  },

  down: queryInterface =>
    queryInterface.removeColumn(
      ['category', 'products', 'orders', 'purchases'],
      'isDeleted',
    ),
}

当我使用sequelize db:migrate运行此脚本时,出现错误

== 20181212035825-add-column-for-deleted-items: migrating =======

ERROR: s.replace is not a function

有没有办法可以做到这一点?我一直在使用此资源作为参考 https://sequelize.readthedocs.io/en/latest/docs/migrations/

0 个答案:

没有答案