I have a db - Postgresql v11.3 and Sequel with pg_enum, so how I can remove value from enum type? For example, need change column enum type :
Sequel.migration do
up do
removed_values = %w["val1" "val2"]
remove_enum_value= (:old_enum_type, removed_values)
create_enum(
:enum_column,
%w[val3 val4]
)
alter_table :users do
set_column_type(
:enum_column,
'enum_column[]',
using: 'old_enum_column::text[]:::enum_column[]'
)
set_column_default :enum_column, '{}'
end
end
end
New enum type same as previous, with little different - new type doesn't have a some values. But, may be situation if somebody use missing values - migration will be crashed. Unfortunatly, pg_enum don't have a method, that will able simple remove enum value
If you review https://www.postgresql.org/docs/12/sql-altertype.html, you will see that PostgreSQL supports adding and renaming enum values, but not removing them.