DEV Community

Discussion on: Dealing with Enum Type in PostgreSQL

Collapse
 
crazyoptimist profile image
crazyoptimist

Hey Yogi, thanks for the great post.
How are you handling migrations where some of the enum values are removed? Existing data are using an enum value which should be removed now.
For example, you have this enum ('PREPARING', 'WAITING_PICKUP',
'IN_DELIVERY', 'DELIVERED', 'OTHERS')
and now PREPARING is to be renamed to PACKAGING. Existing data(a large amount of production one) are using the value 'PREPARING'.

Collapse
 
crazyoptimist profile image
crazyoptimist • Edited

I've figured it out.

ALTER TYPE delivery_status RENAME VALUE 'PREPARING' TO 'PACKAGING' ;
Enter fullscreen mode Exit fullscreen mode

This query worked out brilliantly.
Thanks again.