Postgres enums ============== ERROR: when adding an enum to a table - column "my_column" contains null values -------------------------------------------------------------------------------- ``` CREATE TYPE my_enum AS ENUM ('value1', 'value2'); ALTER TABLE some_table ADD COLUMN my_new_column my_enum NOT NULL; ERROR: column "my_new_column" contains null values ``` - had existing data - new column is not null - hack workaround - remove not-null constraint - real fix: add a default value to the column ``` ALTER TABLE some_table ADD COLUMN my_new_column my_enum NOT NULL DEFAULT 'value1'; ``` - that will take time (adds value to existing rows) - then remove the default ``` ALTER TABLE some_table ALTER COLUMN my_new_column DROP DEFAULT; ```