3

I'm trying to add a column via migration to a particular table. The goal is to add a column type of an array that include enum values

1 Attempt:

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

Result: ERROR: type "public.enum_Locations_tags[]" does not exist

2 Attempt:

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']
      })),
      }
    );

Result: ERROR: type "public.enum_Locations_tags[]" does not exist

Any idea how to solve this Thanks in advance!

Inamul Hassan
  • 138
  • 1
  • 2
  • 11

1 Answers1

1
await queryInterface.addColumn('event-action-item', 'actionTags', {

  type: Sequelize.DataTypes.ARRAY(Sequelize.DataTypes.STRING),

  defaultValue: [],

});
blackcityhenry
  • 691
  • 1
  • 6
  • 22
  • 1
    Your answer could be improved by adding more information on what the code does and how it helps the OP. – Tyler2P Jun 09 '23 at 17:55