Given an existing Postgres DOMAIN with CHECK constraint:
CREATE DOMAIN code as CHAR(1)
CHECK (value IN ('A', 'B', 'C'));
I need to alter the CHECK constraint to add D as a member to the valid set A, B and C.
Since the new constraint is a superset of the first it seemed acceptable to first DROP the existing constraint and then ADD it again; i.e:
ALTER DOMAIN code
DROP CONSTRAINT code_check; -- constraint is implicitly named `code_check`
ALTER DOMAIN code
ADD CONSTRAINT code_check
CHECK (value IN ('A', 'B', 'C', 'D')); -- new constraint
Are there possible issues with this approach, or is there a better method?