execute "CREATE EXTENSION IF NOT EXISTS btree_gist;"
execute """
ALTER TABLE appointments
ADD CONSTRAINT overlapping_appointments
EXCLUDE USING GIST (
doctor_id WITH =,
tsrange("from", "until", '[)') WITH &&
) WHERE (NOT canceled);
"""
end
execute "CREATE EXTENSION IF NOT EXISTS btree_gist;"
execute """
ALTER TABLE appointments
ADD CONSTRAINT overlapping_appointments
EXCLUDE USING GIST (
doctor_id WITH =,
tsrange("from", "until", '[)') WITH &&
) WHERE (NOT canceled);
"""
end