camper/deploy/booking_campsite.sql

26 lines
708 B
MySQL
Raw Normal View History

-- Deploy camper:booking_campsite to pg
-- requires: roles
-- requires: schema_camper
-- requires: booking
-- requires: campsite
-- requires: extension_btree_gist
begin;
set search_path to camper, public;
create table booking_campsite (
booking_id integer not null references booking,
campsite_id integer not null references campsite,
stay daterange not null,
primary key (booking_id, campsite_id, stay),
exclude using gist (campsite_id with =, stay with &&)
);
create index booking_campsite_stay_idx on booking_campsite using gist (stay);
grant select, insert, update, delete on table booking_campsite to employee;
grant select, insert, update, delete on table booking_campsite to admin;
commit;