You can keep your individual timestamp columns and still use the exception constraint in the expression:
CREATE TABLE tbl ( tbl_id serial PRIMARY KEY , starts_at timestamp , ends_at timestamp , EXCLUDE USING gist (tsrange(starts_at, ends_at) WITH &&)
Building a tsrange value without explicit boundaries like tsrange(starts_at, ends_at) automatically accepts standard boundaries: including the lower and upper ones, with the exception of '[)' , which is usually best.
SQL Fiddle
on this topic:
Add constraint to existing table
ALTER TABLE tbl ADD CONSTRAINT tbl_no_overlapping_time_ranges EXCLUDE USING gist (tsrange(starts_at, ends_at) WITH &&)
The syntax details are the same as for CREATE TABLE .
source share