generated from eliona-smart-building-assistant/device-app-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
CREATE TABLE IF NOT EXISTS ews.unified_booking | ||
( | ||
id bigserial PRIMARY KEY, | ||
exchange_uid text UNIQUE, | ||
exchange_organizer_mailbox text, | ||
booking_id int UNIQUE | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS ews.room_booking | ||
( | ||
id bigserial PRIMARY KEY, | ||
unified_booking_id bigserial NOT NULL REFERENCES ews.unified_booking(id) ON DELETE CASCADE, | ||
exchange_id text UNIQUE | ||
); | ||
|
||
INSERT INTO ews.unified_booking (exchange_uid, exchange_organizer_mailbox, booking_id) | ||
SELECT DISTINCT exchange_uid, exchange_mailbox, booking_id | ||
FROM ews.booking; | ||
|
||
INSERT INTO ews.room_booking (unified_booking_id, exchange_id) | ||
SELECT ub.id, b.exchange_id | ||
FROM ews.booking b | ||
JOIN ews.unified_booking ub ON b.exchange_uid = ub.exchange_uid; | ||
|
||
DROP TABLE IF EXISTS ews.booking; |