3

Assuming the following index:

CREATE INDEX CONCURRENTLY blocked_date_idx_on_since_until_range
  ON blocked_date
  USING gist(
    tstzrange(
      "blocked_since",
      "blocked_until",
      '[]'
    )
  );

Which is a range on 2 dates, I'd like to:

ALTER TABLE blocked_date
  ADD CONSTRAINT blocked_date_since_until_overlap
  EXCLUDE
    USING INDEX blocked_date_idx_on_since_until_range WITH &&;

This syntax is not valid (I get an error), but I can't find a valid one where I can specify which operator to use on the index. What is the right syntax for the ALTER TABLE part?

Francesco Belladonna
  • 11,361
  • 12
  • 77
  • 147

1 Answers1

3

Currently there is no syntax to achieve this. You are required to create the constraint directly and can't create the index upfront.

Francesco Belladonna
  • 11,361
  • 12
  • 77
  • 147