Skip to content

.tip

· one of the small things

A lookup table beats an enum the day the list changes

A Postgres enum is fast and typed, and painful to change. You can add values but not remove or reorder them, and renaming one needs a migration on every consumer.

CREATE TABLE order_statuses (code text PRIMARY KEY, label text NOT NULL);
ALTER TABLE orders ADD FOREIGN KEY (status) REFERENCES order_statuses (code);

Use an enum for a list the domain fixes, like days of the week. For anything a product manager might rename, use a table.

postgresqlschema-design