Skip to content

Commit 8ba8889

Browse files
Add required schema changes
Co-Authored-By: Sukhwinder Dhillon <[email protected]>
1 parent c32dfbf commit 8ba8889

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

schema/pgsql/schema.sql

+39
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,31 @@ CREATE TABLE rule_escalation_recipient (
244244
CHECK (num_nonnulls(contact_id, contactgroup_id, schedule_id) = 1)
245245
);
246246

247+
CREATE TABLE rule_routing (
248+
id bigserial,
249+
rule_id bigint NOT NULL REFERENCES rule(id),
250+
position integer NOT NULL,
251+
condition text,
252+
name text, -- if not set, recipients are used as a fallback for display purposes
253+
254+
CONSTRAINT pk_rule_routing PRIMARY KEY (id),
255+
256+
UNIQUE (rule_id, position)
257+
);
258+
259+
CREATE TABLE rule_routing_recipient (
260+
id bigserial,
261+
rule_routing_id bigint NOT NULL REFERENCES rule_routing(id),
262+
contact_id bigint REFERENCES contact(id),
263+
contactgroup_id bigint REFERENCES contactgroup(id),
264+
schedule_id bigint REFERENCES schedule(id),
265+
channel_id bigint REFERENCES channel(id),
266+
267+
CONSTRAINT pk_rule_routing_recipient PRIMARY KEY (id),
268+
269+
CHECK (num_nonnulls(contact_id, contactgroup_id, schedule_id) = 1)
270+
);
271+
247272
CREATE TABLE incident (
248273
id bigserial,
249274
object_id bytea NOT NULL REFERENCES object(id),
@@ -310,3 +335,17 @@ CREATE TABLE incident_history (
310335

311336
CREATE INDEX idx_incident_history_time_type ON incident_history(time, type);
312337
COMMENT ON INDEX idx_incident_history_time_type IS 'Incident History ordered by time/type';
338+
339+
CREATE TABLE notification_history (
340+
id bigserial,
341+
incident_id bigint REFERENCES incident(id),
342+
rule_routing_id bigint REFERENCES rule_routing(id),
343+
contact_id bigint REFERENCES contact(id),
344+
contactgroup_id bigint REFERENCES contactgroup(id),
345+
schedule_id bigint REFERENCES schedule(id),
346+
channel_id bigint REFERENCES channel(id),
347+
time bigint NOT NULL,
348+
notification_state notification_state_type,
349+
sent_at bigint,
350+
message text
351+
);
Original file line numberDiff line numberDiff line change
@@ -1 +1,40 @@
11
DROP TABLE incident_event;
2+
3+
CREATE TABLE rule_routing (
4+
id bigserial,
5+
rule_id bigint NOT NULL REFERENCES rule(id),
6+
position integer NOT NULL,
7+
condition text,
8+
name text, -- if not set, recipients are used as a fallback for display purposes
9+
10+
CONSTRAINT pk_rule_routing PRIMARY KEY (id),
11+
12+
UNIQUE (rule_id, position)
13+
);
14+
15+
CREATE TABLE rule_routing_recipient (
16+
id bigserial,
17+
rule_routing_id bigint NOT NULL REFERENCES rule_routing(id),
18+
contact_id bigint REFERENCES contact(id),
19+
contactgroup_id bigint REFERENCES contactgroup(id),
20+
schedule_id bigint REFERENCES schedule(id),
21+
channel_id bigint REFERENCES channel(id),
22+
23+
CONSTRAINT pk_rule_routing_recipient PRIMARY KEY (id),
24+
25+
CHECK (num_nonnulls(contact_id, contactgroup_id, schedule_id) = 1)
26+
);
27+
28+
CREATE TABLE notification_history (
29+
id bigserial,
30+
incident_id bigint REFERENCES incident(id),
31+
rule_routing_id bigint REFERENCES rule_routing(id),
32+
contact_id bigint REFERENCES contact(id),
33+
contactgroup_id bigint REFERENCES contactgroup(id),
34+
schedule_id bigint REFERENCES schedule(id),
35+
channel_id bigint REFERENCES channel(id),
36+
time bigint NOT NULL,
37+
notification_state notification_state_type,
38+
sent_at bigint,
39+
message text
40+
);

0 commit comments

Comments
 (0)