Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions schema/mysql/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ CREATE INDEX idx_contactgroup_member_changed_at ON contactgroup_member(changed_a
CREATE TABLE schedule (
id bigint NOT NULL AUTO_INCREMENT,
name text NOT NULL COLLATE utf8mb4_unicode_ci,
timezone text NOT NULL, -- e.g. 'Europe/Berlin'

changed_at bigint NOT NULL,
deleted enum('n', 'y') NOT NULL DEFAULT 'n',
Expand Down
12 changes: 12 additions & 0 deletions schema/mysql/upgrades/0.2.0-schedule-timezone.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ALTER TABLE schedule ADD COLUMN timezone text AFTER name;
UPDATE schedule SET timezone = (
SELECT entry.timezone
FROM timeperiod_entry entry
INNER JOIN timeperiod ON timeperiod.id = entry.timeperiod_id
INNER JOIN rotation ON rotation.id = timeperiod.owned_by_rotation_id
WHERE rotation.schedule_id = schedule.id
ORDER BY entry.id
LIMIT 1
);
UPDATE schedule SET timezone = 'UTC' WHERE timezone IS NULL;
ALTER TABLE schedule MODIFY COLUMN timezone text NOT NULL;
1 change: 1 addition & 0 deletions schema/pgsql/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ CREATE INDEX idx_contactgroup_member_changed_at ON contactgroup_member(changed_a
CREATE TABLE schedule (
id bigserial,
name citext NOT NULL,
timezone text NOT NULL, -- e.g. 'Europe/Berlin'

changed_at bigint NOT NULL,
deleted boolenum NOT NULL DEFAULT 'n',
Expand Down
12 changes: 12 additions & 0 deletions schema/pgsql/upgrades/0.2.0-schedule-timezone.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ALTER TABLE schedule ADD COLUMN timezone text;
UPDATE schedule SET timezone = (
SELECT entry.timezone
FROM timeperiod_entry entry
INNER JOIN timeperiod ON timeperiod.id = entry.timeperiod_id
INNER JOIN rotation ON rotation.id = timeperiod.owned_by_rotation_id
WHERE rotation.schedule_id = schedule.id
ORDER BY entry.id
LIMIT 1
);
UPDATE schedule SET timezone = 'UTC' WHERE timezone IS NULL;
ALTER TABLE schedule ALTER COLUMN timezone SET NOT NULL;
Loading