Last active
December 8, 2016 03:21
-
-
Save tynor/ff66654b900e7feadbe3ade3ad9317b5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE years ( | |
id uuid PRIMARY KEY, | |
start_date date NOT NULL, | |
end_date date NOT NULL, | |
CHECK (start_date < end_date), | |
CONSTRAINT overlapping_dates EXCLUDE USING GIST ( | |
box( | |
point(date_part('epoch', start_date), date_part('epoch', start_date)), | |
point(date_part('epoch', end_date), date_part('epoch', end_date)) | |
) WITH && | |
) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment