Add value to Postgres enum type, dropping tho...
An enum type in Postgres is a type that can restrict a value to only certain values. It can be defined like this:
create type fruit as Enum ('orange', 'apple');
We can now cast a string to a fruit.
chriserin=# select 'orange'::fruit;
fruit
--------
orange
Well... some strings...
chriserin=# select 'rasberry'::fruit;
ERROR: invalid input value for enum fruit: "rasberry"
It's all good! We can add rasberry
to the enum type.
chriserin=# alter type fruit add value 'rasberry';
chriserin=# select 'rasberry'::fruit;
fruit
----------
rasberry
Postgres allows you to add values to an enum type, but you can't drop values which is a bit of an inconvenience when creating up/down db migrations like you do in Rails or with a tool like tern.
Tweet