[icinga-checkins] icinga.org: icingaweb2-module-director/master: schema: add icinga_service_set_inheritance...

git at icinga.org git at icinga.org
Wed Oct 12 10:08:18 CEST 2016


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

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

schema: add icinga_service_set_inheritance...

...and fix NULL constraints

---

 schema/mysql-migrations/upgrade_115.sql |   23 +++++++++++++++++++++++
 schema/mysql.sql                        |   22 ++++++++++++++++++++--
 schema/pgsql-migrations/upgrade_115.sql |   28 ++++++++++++++++++++++++++++
 schema/pgsql.sql                        |   28 +++++++++++++++++++++++++---
 4 files changed, 96 insertions(+), 5 deletions(-)

diff --git a/schema/mysql-migrations/upgrade_115.sql b/schema/mysql-migrations/upgrade_115.sql
new file mode 100644
index 0000000..45f6236
--- /dev/null
+++ b/schema/mysql-migrations/upgrade_115.sql
@@ -0,0 +1,23 @@
+CREATE TABLE icinga_service_set_inheritance (
+  service_set_id INT(10) UNSIGNED NOT NULL,
+  parent_service_set_id INT(10) UNSIGNED NOT NULL,
+  weight MEDIUMINT UNSIGNED DEFAULT NULL,
+  PRIMARY KEY (service_set_id, parent_service_set_id),
+  UNIQUE KEY unique_order (service_set_id, weight),
+  CONSTRAINT icinga_service_set_inheritance_set
+  FOREIGN KEY host (service_set_id)
+  REFERENCES icinga_service_set (id)
+    ON DELETE CASCADE
+    ON UPDATE CASCADE,
+  CONSTRAINT icinga_service_set_inheritance_parent
+  FOREIGN KEY host (parent_service_set_id)
+  REFERENCES icinga_service_set (id)
+    ON DELETE RESTRICT
+    ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+ALTER TABLE icinga_service_set MODIFY description TEXT DEFAULT NULL;
+
+INSERT INTO director_schema_migration
+  (schema_version, migration_time)
+  VALUES (115, NOW());
diff --git a/schema/mysql.sql b/schema/mysql.sql
index 7931906..70365fd 100644
--- a/schema/mysql.sql
+++ b/schema/mysql.sql
@@ -675,7 +675,7 @@ CREATE TABLE icinga_service_set (
   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,
+  description TEXT DEFAULT NULL,
   PRIMARY KEY (id),
   UNIQUE KEY object_key (object_name, host_id)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -696,6 +696,24 @@ CREATE TABLE icinga_service_set_service (
     ON UPDATE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
+CREATE TABLE icinga_service_set_inheritance (
+  service_set_id INT(10) UNSIGNED NOT NULL,
+  parent_service_set_id INT(10) UNSIGNED NOT NULL,
+  weight MEDIUMINT UNSIGNED DEFAULT NULL,
+  PRIMARY KEY (service_set_id, parent_service_set_id),
+  UNIQUE KEY unique_order (service_set_id, weight),
+  CONSTRAINT icinga_service_set_inheritance_set
+  FOREIGN KEY host (service_set_id)
+  REFERENCES icinga_service_set (id)
+    ON DELETE CASCADE
+    ON UPDATE CASCADE,
+  CONSTRAINT icinga_service_set_inheritance_parent
+  FOREIGN KEY host (parent_service_set_id)
+  REFERENCES icinga_service_set (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,
@@ -1378,4 +1396,4 @@ CREATE TABLE sync_run (
 
 INSERT INTO director_schema_migration
   SET migration_time = NOW(),
-      schema_version = 114;
+      schema_version = 115;
diff --git a/schema/pgsql-migrations/upgrade_115.sql b/schema/pgsql-migrations/upgrade_115.sql
new file mode 100644
index 0000000..0846355
--- /dev/null
+++ b/schema/pgsql-migrations/upgrade_115.sql
@@ -0,0 +1,28 @@
+CREATE TABLE icinga_service_set_inheritance (
+  service_set_id integer NOT NULL,
+  parent_service_set_id integer NOT NULL,
+  weight integer DEFAULT NULL,
+  PRIMARY KEY (service_set_id, parent_service_set_id),
+  CONSTRAINT icinga_service_set_inheritance_set
+  FOREIGN KEY (service_set_id)
+  REFERENCES icinga_service_set (id)
+  ON DELETE CASCADE
+  ON UPDATE CASCADE,
+  CONSTRAINT icinga_service_set_inheritance_parent
+  FOREIGN KEY (parent_service_set_id)
+  REFERENCES icinga_service_set (id)
+  ON DELETE RESTRICT
+  ON UPDATE CASCADE
+);
+
+CREATE UNIQUE INDEX service_set_inheritance_unique_order ON icinga_service_set_inheritance (service_set_id, weight);
+CREATE INDEX service_set_inheritance_set ON icinga_service_set_inheritance (service_set_id);
+CREATE INDEX service_set_inheritance_parent ON icinga_service_set_inheritance (parent_service_set_id);
+
+
+ALTER TABLE icinga_service_set ALTER COLUMN host_id DROP NOT NULL;
+ALTER TABLE icinga_service_set ALTER COLUMN description DROP NOT NULL;
+
+INSERT INTO director_schema_migration
+  (schema_version, migration_time)
+  VALUES (115, NOW());
diff --git a/schema/pgsql.sql b/schema/pgsql.sql
index 01791be..9a82cbc 100644
--- a/schema/pgsql.sql
+++ b/schema/pgsql.sql
@@ -844,10 +844,10 @@ CREATE INDEX host_service_service ON icinga_host_service (service_id);
 
 CREATE TABLE icinga_service_set (
   id serial,
-  host_id integer NOT NULL,
+  host_id integer DEFAULT NULL,
   object_name character varying(128) NOT NULL,
   object_type enum_object_type_all NOT NULL,
-  description text NOT NULL,
+  description text DEFAULT NULL,
   PRIMARY KEY (id)
 );
 
@@ -871,6 +871,28 @@ CREATE TABLE icinga_service_set_service (
 );
 
 
+CREATE TABLE icinga_service_set_inheritance (
+  service_set_id integer NOT NULL,
+  parent_service_set_id integer NOT NULL,
+  weight integer DEFAULT NULL,
+  PRIMARY KEY (service_set_id, parent_service_set_id),
+  CONSTRAINT icinga_service_set_inheritance_set
+  FOREIGN KEY (service_set_id)
+  REFERENCES icinga_service_set (id)
+  ON DELETE CASCADE
+  ON UPDATE CASCADE,
+  CONSTRAINT icinga_service_set_inheritance_parent
+  FOREIGN KEY (parent_service_set_id)
+  REFERENCES icinga_service_set (id)
+  ON DELETE RESTRICT
+  ON UPDATE CASCADE
+);
+
+CREATE UNIQUE INDEX service_set_inheritance_unique_order ON icinga_service_set_inheritance (service_set_id, weight);
+CREATE INDEX service_set_inheritance_set ON icinga_service_set_inheritance (service_set_id);
+CREATE INDEX service_set_inheritance_parent ON icinga_service_set_inheritance (parent_service_set_id);
+
+
 CREATE TABLE icinga_service_set_assignment (
   id serial,
   service_set_id integer NOT NULL,
@@ -1605,4 +1627,4 @@ CREATE UNIQUE INDEX notification_inheritance ON icinga_notification_inheritance
 
 INSERT INTO director_schema_migration
   (schema_version, migration_time)
-  VALUES (114, NOW());
+  VALUES (115, NOW());



More information about the icinga-checkins mailing list