X-Git-Url: https://git.rohieb.name/iserv-mod-room-reservation.git/blobdiff_plain/acb7976b2c4752b087fa187f10ec5f51c0a7b1d2..ce63b9c371709177de3f8aeec14b8d4229c8c91e:/sql/mod_room-reservation.sql diff --git a/sql/mod_room-reservation.sql b/sql/mod_room-reservation.sql index b6bfd65..f29e82a 100644 --- a/sql/mod_room-reservation.sql +++ b/sql/mod_room-reservation.sql @@ -1,38 +1,42 @@ --- --- Table with rooms allowed for booking --- -CREATE TABLE mod_roomreservation_roomswhitelist ( - rrr_name TEXT UNIQUE REFERENCES rooms(name) - ON DELETE CASCADE - ON UPDATE CASCADE -); - --- --- Table with bookings --- -CREATE TABLE mod_roomreservation_bookings ( - rrb_uid SERIAL NOT NULL PRIMARY KEY, -- Unique ID - rrb_room TEXT NOT NULL -- Name of the room - REFERENCES rooms(name) - ON DELETE CASCADE - ON UPDATE CASCADE, - rrb_date DATE NOT NULL, -- Date of the booking - rrb_tsfirst SMALLINT NOT NULL, -- Number of the first timeslice - rrb_tslast SMALLINT NOT NULL -- Number of the last timeslice - CHECK(rrb_tsfirst <= rrb_tslast), - rrb_act TEXT NOT NULL -- Owner of the booking - REFERENCES users(Act) - ON DELETE CASCADE - ON UPDATE CASCADE, - rrb_reason TEXT NOT NULL, -- Reason - rrb_interval SMALLINT NOT NULL -- Interval in weeks for recurring bookings - DEFAULT 0 -); - --- --- Permissions --- -GRANT SELECT, INSERT, UPDATE, DELETE ON mod_roomreservation_bookings, mod_roomreservation_bookings_rrb_uid_seq TO webusr; -GRANT SELECT, INSERT, UPDATE, DELETE ON mod_roomreservation_bookings, mod_roomreservation_bookings_rrb_uid_seq TO webadm; -GRANT SELECT ON mod_roomreservation_roomswhitelist TO webusr; -GRANT SELECT, INSERT, UPDATE, DELETE ON mod_roomreservation_roomswhitelist TO webadm; +-- +-- Table with rooms allowed for booking +-- +CREATE TABLE mod_roomreservation_roomswhitelist ( + rrr_name TEXT UNIQUE REFERENCES rooms(name) + ON DELETE CASCADE + ON UPDATE CASCADE +); + +-- +-- Table with bookings +-- +CREATE TABLE mod_roomreservation_bookings ( + rrb_uid SERIAL NOT NULL -- Unique ID + PRIMARY KEY, + rrb_room TEXT NOT NULL -- Name of the room + REFERENCES rooms(name) + ON DELETE CASCADE + ON UPDATE CASCADE, + rrb_date DATE NOT NULL, -- Date of the booking + rrb_tsfirst SMALLINT NOT NULL, -- Number of the first timeslice + rrb_tslast SMALLINT NOT NULL -- Number of the last timeslice + CHECK(rrb_tsfirst <= rrb_tslast), + rrb_act TEXT NOT NULL -- Owner of the booking + REFERENCES users(Act) + ON DELETE CASCADE + ON UPDATE CASCADE, + rrb_reason TEXT NOT NULL, -- Reason + rrb_interval SMALLINT NOT NULL -- Interval in weeks for + DEFAULT 0 -- recurring bookings +); + +-- +-- Permissions +-- +GRANT SELECT, INSERT, UPDATE, DELETE ON mod_roomreservation_bookings, + mod_roomreservation_bookings_rrb_uid_seq TO webusr; +GRANT SELECT, INSERT, UPDATE, DELETE ON mod_roomreservation_bookings, + mod_roomreservation_bookings_rrb_uid_seq TO webadm; +GRANT SELECT ON mod_roomreservation_roomswhitelist TO webusr; +GRANT SELECT, INSERT, UPDATE, DELETE ON mod_roomreservation_roomswhitelist + TO webadm;