I am refactoring my database constraint for such a table:
CREATE TABLE products (
name text NOT NULL,
status text NOT NULL
);
A former engineer working on the project had such a constraint:
ALTER TABLE products
ADD CONSTRAINT unique_active_name
EXCLUDE (name WITH =)
WHERE (status = 'active' AND name <> '');
I am wondering if it is equivalent to such a partial unique index:
CREATE UNIQUE INDEX unique_active_name
ON products(name)
WHERE (status = 'active' AND name <> '');
I did not quite get the documentation for EXCLUDE
, and would like to improve things. Thanks in advance!