From dece1ac2dc4554f66f8ec194269cd91d330edae1 Mon Sep 17 00:00:00 2001
From: Gibheer <gibheer+git@zero-knowledge.org>
Date: Tue, 11 Dec 2018 12:37:30 +0100
Subject: add level mappings

This allows to map the command exit codes to any other output level
which can then be reported by the notification plugin.
With the provided colors, the frontend will show them accordingly.
---
 schema/20181210.sql | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

(limited to 'schema/20181210.sql')

diff --git a/schema/20181210.sql b/schema/20181210.sql
index 757055d..05236ca 100644
--- a/schema/20181210.sql
+++ b/schema/20181210.sql
@@ -1,3 +1,18 @@
+create table public.mappings(
+  id serial primary key,
+  name text not null,
+  description text not null
+);
+
+create table public.mapping_level(
+  mapping_id integer not null,
+  source int not null,
+  target int not null,
+  title text not null,
+  color text not null,
+  unique(mapping_id, source)
+);
+
 CREATE TABLE public.notifier (
     id serial NOT NULL primary key,
     name text NOT NULL
@@ -10,10 +25,11 @@ CREATE TABLE public.groups (
 
 CREATE TABLE public.nodes (
     id bigserial NOT NULL primary key,
+    mapping_id int references mappings(id),
     name text NOT NULL,
     updated timestamp with time zone DEFAULT now() NOT NULL,
     created timestamp with time zone DEFAULT now() NOT NULL,
-    message text NOT NULL
+    message text NOT NULL,
 );
 
 CREATE TABLE public.nodes_groups (
@@ -28,13 +44,14 @@ CREATE TABLE public.commands (
     command text NOT NULL,
     updated timestamp with time zone DEFAULT now() NOT NULL,
     created timestamp with time zone DEFAULT now() NOT NULL,
-    message text NOT NULL
+    message text NOT NULL,
 );
 
 CREATE TABLE public.checks (
     id bigserial NOT NULL primary key,
     node_id integer not null references nodes(id) on delete cascade,
     command_id integer not null references commands(id) on delete restrict,
+    mapping_id int references mappings(id),
     intval interval DEFAULT '00:05:00'::interval NOT NULL,
     options jsonb DEFAULT '{}'::jsonb NOT NULL,
     updated timestamp with time zone DEFAULT now() NOT NULL,
@@ -48,6 +65,7 @@ CREATE TABLE public.checks (
 
 CREATE TABLE public.active_checks (
     check_id bigint NOT NULL references checks(id) on delete cascade,
+    mapping_id int not null references mappings(id),
     cmdline text[] NOT NULL,
     next_time timestamp with time zone DEFAULT now() NOT NULL,
     states integer[] DEFAULT ARRAY[0] NOT NULL,
-- 
cgit v1.3

