SQL ENUM Modification
I'm doing a little DB work recently, and needing to choose how to represent certain data in the database. For a few fields, ENUM would be the correct choice, but there's a possibility I would need to expand the ENUM later to add values.
My question: is this safe?
The short answer, in my research, is "yes", but with caveats.
For Postgres, it's trivial; you can easily add values to ENUM types:
ALTER TYPE some_previously_defined_enum ADD VALUE 'new-value';
For MySQL, it's a bit more complex. ENUMs are defined within the table schema, and to change them, you use an ALTER TABLE statement:
ALTER TABLE some_table
MODIFY some_previously_defined_enum ENUM('value-1','value-2');
Essentially, you're replacing the definition. This is fine... so long as you don't change the order, or remove any previously defined value in the ENUM. In other words, append to the existing list if you want to safely change it.