From c31e435168bc7e224f1c0b7a84b2bac0b3d21c07 Mon Sep 17 00:00:00 2001 From: Zdenek Devaty Date: Wed, 22 May 2024 10:23:11 +0200 Subject: [PATCH] Add patch for v0.2.0 --- app.go | 4 ++++ conf/000200.sql | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 conf/000200.sql diff --git a/app.go b/app.go index b45b73e..a153781 100644 --- a/app.go +++ b/app.go @@ -55,6 +55,10 @@ func initialization() { asset.InitAssetTypeFiles("resources/asset-types/*.json"), dashboard.InitWidgetTypeFiles("resources/widget-types/*.json"), ) + + app.Patch(conn, app.AppName(), "000201", + app.ExecSqlFile("conf/000200.sql"), + ) } var once sync.Once diff --git a/conf/000200.sql b/conf/000200.sql new file mode 100644 index 0000000..149624a --- /dev/null +++ b/conf/000200.sql @@ -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;