0

I would like to add a deferrable unique constraint with a check, such as

ALTER TABLE locations 
   ADD CONSTRAINT short_name 
    UNIQUE (hallway, row, module, level, position, zone_id) 
    CHECK (active) DEFERRABLE

But it is not possible.

Context: I have a table in which a given combination of fields must be unique, just when the field active is set on true (Possible CHECK?). Normally we receive a list of updates that must be performed as an atomic transaction, that is why the constraint must be deferrable.

The answer to this question shows as an option one UNIQUE INDEX, but it is not deferrable.

Is there any possible solution or workaround?

0 Answers0