[icinga-checkins] icinga.org: icingaweb2-module-director/master: schema: get rid of service_set_service, introduce

git at icinga.org git at icinga.org
Thu Oct 27 18:37:05 CEST 2016


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

Author: Thomas Gelf <thomas at gelf.net>
Date:   Tue Oct 25 22:57:10 2016 +0000

schema: get rid of service_set_service, introduce

...a service_set_id column directly on the service

---

 schema/mysql-migrations/upgrade_121.sql |    8 ++++++++
 schema/mysql.sql                        |   19 ++-----------------
 schema/pgsql-migrations/upgrade_121.sql |    8 ++++++++
 schema/pgsql.sql                        |   20 ++------------------
 4 files changed, 20 insertions(+), 35 deletions(-)

diff --git a/schema/mysql-migrations/upgrade_121.sql b/schema/mysql-migrations/upgrade_121.sql
new file mode 100644
index 0000000..24c307a
--- /dev/null
+++ b/schema/mysql-migrations/upgrade_121.sql
@@ -0,0 +1,8 @@
+ALTER TABLE icinga_service
+  ADD COLUMN service_set_id INT(10) UNSIGNED DEFAULT NULL AFTER host_id;
+
+DROP TABLE icinga_service_set_service;
+
+INSERT INTO director_schema_migration
+  (schema_version, migration_time)
+  VALUES (121, NOW());
diff --git a/schema/mysql.sql b/schema/mysql.sql
index c6a4932..a6e46ed 100644
--- a/schema/mysql.sql
+++ b/schema/mysql.sql
@@ -535,6 +535,7 @@ CREATE TABLE icinga_service (
   disabled ENUM('y', 'n') NOT NULL DEFAULT 'n',
   display_name VARCHAR(255) DEFAULT NULL,
   host_id INT(10) UNSIGNED DEFAULT NULL,
+  service_set_id INT(10) UNSIGNED DEFAULT NULL,
   check_command_id INT(10) UNSIGNED DEFAULT NULL,
   max_check_attempts MEDIUMINT UNSIGNED DEFAULT NULL,
   check_period_id INT(10) UNSIGNED DEFAULT NULL,
@@ -670,22 +671,6 @@ CREATE TABLE icinga_service_set (
   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_inheritance (
   service_set_id INT(10) UNSIGNED NOT NULL,
   parent_service_set_id INT(10) UNSIGNED NOT NULL,
@@ -1369,4 +1354,4 @@ CREATE TABLE sync_run (
 
 INSERT INTO director_schema_migration
   (schema_version, migration_time)
-  VALUES (120, NOW());
+  VALUES (121, NOW());
diff --git a/schema/pgsql-migrations/upgrade_121.sql b/schema/pgsql-migrations/upgrade_121.sql
new file mode 100644
index 0000000..f6a1050
--- /dev/null
+++ b/schema/pgsql-migrations/upgrade_121.sql
@@ -0,0 +1,8 @@
+ALTER TABLE icinga_service
+  ADD COLUMN service_set_id integer DEFAULT NULL;
+
+DROP TABLE icinga_service_set_service;
+
+INSERT INTO director_schema_migration
+  (schema_version, migration_time)
+  VALUES (121, NOW());
diff --git a/schema/pgsql.sql b/schema/pgsql.sql
index 2f2cea0..84fd2ac 100644
--- a/schema/pgsql.sql
+++ b/schema/pgsql.sql
@@ -677,6 +677,7 @@ CREATE TABLE icinga_service (
   disabled enum_boolean DEFAULT 'n',
   display_name character varying(255) DEFAULT NULL,
   host_id INTEGER DEFAULT NULL,
+  service_set_id integer DEFAULT NULL,
   check_command_id integer DEFAULT NULL,
   max_check_attempts integer DEFAULT NULL,
   check_period_id integer DEFAULT NULL,
@@ -838,23 +839,6 @@ CREATE TABLE icinga_service_set (
 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_inheritance (
   service_set_id integer NOT NULL,
   parent_service_set_id integer NOT NULL,
@@ -1597,4 +1581,4 @@ CREATE UNIQUE INDEX notification_inheritance ON icinga_notification_inheritance
 
 INSERT INTO director_schema_migration
   (schema_version, migration_time)
-  VALUES (120, NOW());
+  VALUES (121, NOW());



More information about the icinga-checkins mailing list