0

I'm trying to create a table containing opening hours (for cafeteria's) However I am having some issues with implementing the constraint. For each resto, the openinghours cannot overlap.

CREATE table openinghours(
    id serial PRIMARY key,
    start timestamp NOT NULL,
    duration interval NOT NULL,
    resto_naam varchar REFERENCES resto(naam),
    constraint openingstijden_duplicate_check EXCLUDE USING GIST (
        resto_naam WITH =,
        /* Check wether there is no overlap between the dates */
        tsrange(start, start + duration) WITH &&
    )
);

when I try to execute this SQL I get the following error:

ERROR: data type character varying has no default operator class for access method "gist" HINT: You must specify an operator class for the index or define a default operator class for the data type. SQL state: 42704

Any help would be appreciated!

1 Answer 1

1

You need the btree_gist extension for this to work. Execute create btree_gist and try again.

Best regards,
Bjarni

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.