aboutsummaryrefslogtreecommitdiff
path: root/schema/20181210.sql
diff options
context:
space:
mode:
authorGibheer <gibheer+git@zero-knowledge.org>2018-12-11 20:21:14 +0100
committerGibheer <gibheer+git@zero-knowledge.org>2018-12-11 20:21:14 +0100
commitaf843d76e1aff287af3d07dd5890f814991e662a (patch)
treeac2fd386ab0059c03add6e602a5dfa13862e4344 /schema/20181210.sql
parent02e8142b6df146272bdcaba6d7f481061540cebe (diff)
moncheck - move notifications to dedicated table
It would be nice to support multiple notification mechanisms with a way to disable all or part of them. So for now, this is bound to the check but may change again in the future. Apart from that, all notifications get written to the notification table, so that the notifiers can do their job and ACK their own notifications.
Diffstat (limited to 'schema/20181210.sql')
-rw-r--r--schema/20181210.sql16
1 files changed, 11 insertions, 5 deletions
diff --git a/schema/20181210.sql b/schema/20181210.sql
index e6be91d..c807863 100644
--- a/schema/20181210.sql
+++ b/schema/20181210.sql
@@ -15,7 +15,8 @@ create table public.mapping_level(
CREATE TABLE public.notifier (
id serial NOT NULL primary key,
- name text NOT NULL
+ name text NOT NULL,
+ settings jsonb not null '{}'::jsonb,
);
CREATE TABLE public.groups (
@@ -57,8 +58,6 @@ CREATE TABLE public.checks (
updated timestamp with time zone DEFAULT now() NOT NULL,
last_refresh timestamp with time zone,
enabled boolean DEFAULT true NOT NULL,
- notifier_id integer NOT NULL,
- notify boolean DEFAULT true NOT NULL,
message text NOT NULL,
unique(node_id, command_id, options)
);
@@ -71,20 +70,27 @@ CREATE TABLE public.active_checks (
states integer[] DEFAULT ARRAY[0] NOT NULL,
intval interval NOT NULL,
enabled boolean NOT NULL,
- notify boolean NOT NULL,
notice text,
msg text NOT NULL,
acknowledged boolean DEFAULT false NOT NULL
);
+create table checks_notify(
+ check_id bigint not null references checks(id),
+ notifier_id bigint not null references notifier(id),
+ enabled bool not null default true,
+ unique(check_id, notifier_id)
+);
+
CREATE TABLE public.notifications (
id bigserial NOT NULL primary key,
check_id bigint NOT NULL references checks(id) on delete cascade,
+ mapping_id integer not null references mappings(id),
+ notifier_id integer not null references notifier(id),
states integer[] NOT NULL,
output text,
inserted timestamp with time zone DEFAULT now() NOT NULL,
sent timestamp with time zone,
- mapping_id integer not null references mappings(id),
);