NodeJS 序列化迁移添加阵列列

bxfogqkk  于 2023-06-05  发布在  Node.js
关注(0)|答案(1)|浏览(130)

我试图通过迁移将列添加到特定的表。目标是添加包含枚举值的数组的列类型

1次尝试:

await queryInterface.addColumn(
      'Locations',
      'tags',
      {
        type: Sequelize.ARRAY(Sequelize.ENUM({
          values: ['Competitor', 'Multi Location', 'Duplicate']
      })),
      }
    );

***结果:***ERROR: type "public.enum_Locations_tags[]" does not exist
2次尝试:

await queryInterface.sequelize.query("CREATE TYPE enum_Locations_tags AS ENUM ('Competitor', 'Multi Location', 'Duplicate');");
    await queryInterface.addColumn(
      'Locations',
      'tags',
      {
        type: Sequelize.ARRAY(Sequelize.ENUM({
          values: ['Competitor', 'Multi Location', 'Duplicate']
      })),
      }
    );

***结果:***ERROR: type "public.enum_Locations_tags[]" does not exist

任何想法如何解决这个问题,提前感谢!

5lhxktic

5lhxktic1#

await queryInterface.addColumn('event-action-item', 'actionTags', {
  type: Sequelize.DataTypes.ARRAY(Sequelize.DataTypes.STRING),
  defaultValue: [],
});

相关问题