Loading section...

ENUM Traps

ENUM types look like a clean way to constrain a column to a fixed set of values: status can only be 'active', 'inactive', or 'suspended'. The problem is that the set of values is baked into the schema. Adding a new status requires an ALTER TABLE, which in some databases locks the table or requires a migration. In production, the set of valid values almost always grows. The ALTER TABLE Problem In PostgreSQL, adding a value to an ENUM type is fast (ALTER TYPE ... ADD VALUE). But removing or renaming a value is not supported. You must create a new type, migrate the column, and drop the old type. In MySQL, ALTER TABLE on an ENUM column rewrites the entire table. On a billion-row table, that is an hours-long operation that locks writes. A lookup table with a FK is the production-safe alternativ