[icinga-checkins] icinga.org: icingaweb2-module-director/master: schema: add service set tables

git at icinga.org git at icinga.org
Wed Oct 12 09:04:01 CEST 2016


Module: icingaweb2-module-director
Branch: master
Commit: 1a03cea5d7ee4d2bd85479192815f8c82a9ff5ba
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=1a03cea5d7ee4d2bd85479192815f8c82a9ff5ba

Author: Thomas Gelf <thomas at gelf.net>
Date:   Wed Oct 12 07:03:51 2016 +0000

schema: add service set tables

---

 schema/mysql-migrations/upgrade_114.sql |   55 +++++++++++++++++++++++++++
 schema/mysql.sql                        |   56 ++++++++++++++++++++++++++-
 schema/pgsql-migrations/upgrade_114.sql |   63 +++++++++++++++++++++++++++++++
 schema/pgsql.sql                        |   62 +++++++++++++++++++++++++++++-
 4 files changed, 233 insertions(+), 3 deletions(-)

diff --git a/schema/mysql-migrations/upgrade_114.sql b/schema/mysql-migrations/upgrade_114.sql
new file mode 100644
index 0000000..24d3430
--- /dev/null
+++ b/schema/mysql-migrations/upgrade_114.sql
@@ -0,0 +1,55 @@
+CREATE TABLE icinga_service_set (
+  id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+  object_name VARCHAR(128) NOT NULL,
+  object_type ENUM('object', 'template', 'external_object') NOT NULL,
+  host_id INT(10) UNSIGNED DEFAULT NULL,
+  description TEXT NOT NULL,
+  PRIMARY KEY (id),
+  UNIQUE KEY object_key (object_name, host_id)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE icinga_service_set_service (
+  service_set_id INT(10) UNSIGNED NOT NULL,
+  service_id INT(10) UNSIGNED NOT NULL,
+  PRIMARY KEY (service_set_id, service_id),
+  CONSTRAINT service_set_set
+    FOREIGN KEY service_set (service_set_id)
+    REFERENCES icinga_service_set (id)
+    ON DELETE CASCADE
+    ON UPDATE CASCADE,
+  CONSTRAINT service_set_service
+    FOREIGN KEY service (service_id)
+    REFERENCES icinga_service (id)
+    ON DELETE RESTRICT
+    ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE icinga_service_set_assignment (
+  id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+  service_set_id INT(10) UNSIGNED NOT NULL,
+  filter_string TEXT NOT NULL,
+  assign_type ENUM('assign', 'ignore') NOT NULL DEFAULT 'assign',
+  PRIMARY KEY (id),
+  CONSTRAINT icinga_service_set_assignment
+    FOREIGN KEY service_set (service_set_id)
+    REFERENCES icinga_service_set (id)
+    ON DELETE CASCADE
+    ON UPDATE CASCADE
+) ENGINE=InnoDB;
+
+CREATE TABLE icinga_service_set_var (
+  service_set_id INT(10) UNSIGNED NOT NULL,
+  varname VARCHAR(255) NOT NULL COLLATE utf8_bin,
+  varvalue TEXT DEFAULT NULL,
+  format ENUM('string', 'expression', 'json') NOT NULL DEFAULT 'string',
+  PRIMARY KEY (service_set_id, varname),
+  CONSTRAINT icinga_service_set_var_service
+    FOREIGN KEY command (service_set_id)
+    REFERENCES icinga_service_set (id)
+    ON DELETE CASCADE
+    ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+INSERT INTO director_schema_migration
+  (schema_version, migration_time)
+  VALUES (114, NOW());
diff --git a/schema/mysql.sql b/schema/mysql.sql
index 658916b..7931906 100644
--- a/schema/mysql.sql
+++ b/schema/mysql.sql
@@ -655,7 +655,7 @@ CREATE TABLE icinga_service_assignment (
 ) ENGINE=InnoDB;
 
 CREATE TABLE icinga_host_service (
-    host_id INT(10) UNSIGNED NOT NULL,
+  host_id INT(10) UNSIGNED NOT NULL,
   service_id INT(10) UNSIGNED NOT NULL,
   PRIMARY KEY (host_id, service_id),
   CONSTRAINT icinga_host_service_host
@@ -670,6 +670,58 @@ CREATE TABLE icinga_host_service (
     ON UPDATE CASCADE
 ) ENGINE=InnoDB;
 
+CREATE TABLE icinga_service_set (
+  id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+  object_name VARCHAR(128) NOT NULL,
+  object_type ENUM('object', 'template', 'external_object') NOT NULL,
+  host_id INT(10) UNSIGNED DEFAULT NULL,
+  description TEXT NOT NULL,
+  PRIMARY KEY (id),
+  UNIQUE KEY object_key (object_name, host_id)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE icinga_service_set_service (
+  service_set_id INT(10) UNSIGNED NOT NULL,
+  service_id INT(10) UNSIGNED NOT NULL,
+  PRIMARY KEY (service_set_id, service_id),
+  CONSTRAINT service_set_set
+    FOREIGN KEY service_set (service_set_id)
+    REFERENCES icinga_service_set (id)
+    ON DELETE CASCADE
+    ON UPDATE CASCADE,
+  CONSTRAINT service_set_service
+    FOREIGN KEY service (service_id)
+    REFERENCES icinga_service (id)
+    ON DELETE RESTRICT
+    ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE icinga_service_set_assignment (
+  id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+  service_set_id INT(10) UNSIGNED NOT NULL,
+  filter_string TEXT NOT NULL,
+  assign_type ENUM('assign', 'ignore') NOT NULL DEFAULT 'assign',
+  PRIMARY KEY (id),
+  CONSTRAINT icinga_service_set_assignment
+    FOREIGN KEY service_set (service_set_id)
+    REFERENCES icinga_service_set (id)
+    ON DELETE CASCADE
+    ON UPDATE CASCADE
+) ENGINE=InnoDB;
+
+CREATE TABLE icinga_service_set_var (
+  service_set_id INT(10) UNSIGNED NOT NULL,
+  varname VARCHAR(255) NOT NULL COLLATE utf8_bin,
+  varvalue TEXT DEFAULT NULL,
+  format ENUM('string', 'expression', 'json') NOT NULL DEFAULT 'string',
+  PRIMARY KEY (service_set_id, varname),
+  CONSTRAINT icinga_service_set_var_service
+    FOREIGN KEY command (service_set_id)
+    REFERENCES icinga_service_set (id)
+    ON DELETE CASCADE
+    ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
 CREATE TABLE icinga_hostgroup (
   id INT(10) UNSIGNED AUTO_INCREMENT NOT NULL,
   object_name VARCHAR(255) NOT NULL,
@@ -1326,4 +1378,4 @@ CREATE TABLE sync_run (
 
 INSERT INTO director_schema_migration
   SET migration_time = NOW(),
-      schema_version = 112;
+      schema_version = 114;
diff --git a/schema/pgsql-migrations/upgrade_114.sql b/schema/pgsql-migrations/upgrade_114.sql
new file mode 100644
index 0000000..6bd3f18
--- /dev/null
+++ b/schema/pgsql-migrations/upgrade_114.sql
@@ -0,0 +1,63 @@
+CREATE TABLE icinga_service_set (
+  id serial,
+  host_id integer NOT NULL,
+  object_name character varying(128) NOT NULL,
+  object_type enum_object_type_all NOT NULL,
+  description text NOT NULL,
+  PRIMARY KEY (id)
+);
+
+CREATE UNIQUE INDEX service_set_name ON icinga_service_set (object_name, host_id);
+
+
+CREATE TABLE icinga_service_set_service (
+  service_set_id serial,
+  service_id serial,
+  PRIMARY KEY (service_set_id, service_id),
+  CONSTRAINT icinga_service_set_set
+    FOREIGN KEY (service_set_id)
+    REFERENCES icinga_service_set (id)
+    ON DELETE CASCADE
+    ON UPDATE CASCADE,
+  CONSTRAINT icinga_service_set_service
+    FOREIGN KEY (service_id)
+    REFERENCES icinga_service (id)
+    ON DELETE RESTRICT
+    ON UPDATE CASCADE
+);
+
+
+CREATE TABLE icinga_service_set_assignment (
+  id serial,
+  service_set_id integer NOT NULL,
+  filter_string text NOT NULL,
+  assign_type enum_assign_type NOT NULL DEFAULT 'assign',
+  PRIMARY KEY (id),
+  CONSTRAINT icinga_service_set_assignment
+    FOREIGN KEY (service_set_id)
+    REFERENCES icinga_service_set (id)
+    ON DELETE CASCADE
+    ON UPDATE CASCADE
+);
+
+
+CREATE TABLE icinga_service_set_var (
+  service_set_id integer NOT NULL,
+  varname character varying(255) NOT NULL,
+  varvalue text DEFAULT NULL,
+  format enum_property_format NOT NULL DEFAULT 'string',
+  PRIMARY KEY (service_set_id, varname),
+  CONSTRAINT icinga_service_set_var_service_set
+  FOREIGN KEY (service_set_id)
+    REFERENCES icinga_service_set (id)
+    ON DELETE CASCADE
+    ON UPDATE CASCADE
+);
+
+CREATE INDEX service_set_var_service_set ON icinga_service_set_var (service_set_id);
+CREATE INDEX service_set_var_search_idx ON icinga_service_set_var (varname);
+
+
+INSERT INTO director_schema_migration
+  (schema_version, migration_time)
+  VALUES (114, NOW());
diff --git a/schema/pgsql.sql b/schema/pgsql.sql
index cb00d15..01791be 100644
--- a/schema/pgsql.sql
+++ b/schema/pgsql.sql
@@ -842,6 +842,66 @@ CREATE INDEX host_service_host ON icinga_host_service (host_id);
 CREATE INDEX host_service_service ON icinga_host_service (service_id);
 
 
+CREATE TABLE icinga_service_set (
+  id serial,
+  host_id integer NOT NULL,
+  object_name character varying(128) NOT NULL,
+  object_type enum_object_type_all NOT NULL,
+  description text NOT NULL,
+  PRIMARY KEY (id)
+);
+
+CREATE UNIQUE INDEX service_set_name ON icinga_service_set (object_name, host_id);
+
+
+CREATE TABLE icinga_service_set_service (
+  service_set_id serial,
+  service_id serial,
+  PRIMARY KEY (service_set_id, service_id),
+  CONSTRAINT icinga_service_set_set
+    FOREIGN KEY (service_set_id)
+    REFERENCES icinga_service_set (id)
+    ON DELETE CASCADE
+    ON UPDATE CASCADE,
+  CONSTRAINT icinga_service_set_service
+    FOREIGN KEY (service_id)
+    REFERENCES icinga_service (id)
+    ON DELETE RESTRICT
+    ON UPDATE CASCADE
+);
+
+
+CREATE TABLE icinga_service_set_assignment (
+  id serial,
+  service_set_id integer NOT NULL,
+  filter_string text NOT NULL,
+  assign_type enum_assign_type NOT NULL DEFAULT 'assign',
+  PRIMARY KEY (id),
+  CONSTRAINT icinga_service_set_assignment
+    FOREIGN KEY (service_set_id)
+    REFERENCES icinga_service_set (id)
+    ON DELETE CASCADE
+    ON UPDATE CASCADE
+);
+
+
+CREATE TABLE icinga_service_set_var (
+  service_set_id integer NOT NULL,
+  varname character varying(255) NOT NULL,
+  varvalue text DEFAULT NULL,
+  format enum_property_format NOT NULL DEFAULT 'string',
+  PRIMARY KEY (service_set_id, varname),
+  CONSTRAINT icinga_service_set_var_service_set
+  FOREIGN KEY (service_set_id)
+    REFERENCES icinga_service_set (id)
+    ON DELETE CASCADE
+    ON UPDATE CASCADE
+);
+
+CREATE INDEX service_set_var_service_set ON icinga_service_set_var (service_set_id);
+CREATE INDEX service_set_var_search_idx ON icinga_service_set_var (varname);
+
+
 CREATE TABLE icinga_hostgroup (
   id serial,
   object_name character varying(255) NOT NULL,
@@ -1545,4 +1605,4 @@ CREATE UNIQUE INDEX notification_inheritance ON icinga_notification_inheritance
 
 INSERT INTO director_schema_migration
   (schema_version, migration_time)
-  VALUES (113, NOW());
+  VALUES (114, NOW());



More information about the icinga-checkins mailing list