Hi there,
The method describing how to change an ENUM
in Active Record and PostgreSQL
is a bit awkward. It put me on the wrong path for a bit. I found you can also change an enum by:
-
renaming it
-
renaming all the columns using it
-
creating a new enum
-
creating a new column using that enum
-
do some copying of values.
Advantages:
-
It runs in a transaction
-
You can add/remove/rename enum values
Here’s a gist of the helper I created to do this in my project: Better migration of enum types · GitHub. Used this on pretty big production tables, no problem. Should we change it?