Reputation: 115
I use PostgreSQL DB and it has an enum type column and it has some enum like a,b,c
now I add one more value like cv-resume in it with this code
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.sequelize.query('ALTER TYPE "enum_Attachment_type" ADD VALUE \'cv-resume\' ')
}
what I should do to undo that in down function and I don't want to delete other enum type data because each type has its own data in Attachment table
Upvotes: 1
Views: 1557
Reputation: 36
From the documentation:
Although enum types are primarily intended for static sets of values, there is support for adding new values to an existing enum type, and for renaming values (see ALTER TYPE). Existing values cannot be removed from an enum type, nor can the sort ordering of such values be changed, short of dropping and re-creating the enum type.
So I don't see any other way to "undo" other than dropping and recreating the enum.
UPDATE: check Drop and create ENUM with sequelize correctly?
Upvotes: 1