diff --git a/schema/mysql-migrations/upgrade_124.sql b/schema/mysql-migrations/upgrade_124.sql new file mode 100644 index 00000000..471c13c6 --- /dev/null +++ b/schema/mysql-migrations/upgrade_124.sql @@ -0,0 +1,21 @@ +ALTER TABLE icinga_service_set + DROP FOREIGN KEY icinga_service_set_host; + +ALTER TABLE icinga_service_set + ADD FOREIGN KEY icinga_service_set_host (host_id) + REFERENCES icinga_host (id) + ON DELETE CASCADE + ON UPDATE CASCADE; + +ALTER TABLE icinga_service + DROP FOREIGN KEY icinga_service_service_set; + +ALTER TABLE icinga_service + ADD CONSTRAINT icinga_service_service_set FOREIGN KEY (service_set_id) + REFERENCES icinga_service_set (id) + ON DELETE CASCADE + ON UPDATE CASCADE; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (124, NOW()); diff --git a/schema/mysql.sql b/schema/mysql.sql index 4fecf709..4dd1c8ea 100644 --- a/schema/mysql.sql +++ b/schema/mysql.sql @@ -541,7 +541,7 @@ CREATE TABLE icinga_service_set ( CONSTRAINT icinga_service_set_host FOREIGN KEY host (host_id) REFERENCES icinga_host (id) - ON DELETE RESTRICT + ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -613,7 +613,7 @@ CREATE TABLE icinga_service ( CONSTRAINT icinga_service_service_set FOREIGN KEY service_set (service_set_id) REFERENCES icinga_service_set (id) - ON DELETE RESTRICT + ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -1365,4 +1365,4 @@ CREATE TABLE sync_run ( INSERT INTO director_schema_migration (schema_version, migration_time) - VALUES (123, NOW()); + VALUES (124, NOW()); diff --git a/schema/pgsql-migrations/upgrade_124.sql b/schema/pgsql-migrations/upgrade_124.sql new file mode 100644 index 00000000..e8b74faa --- /dev/null +++ b/schema/pgsql-migrations/upgrade_124.sql @@ -0,0 +1,21 @@ +ALTER TABLE icinga_service_set + DROP CONSTRAINT icinga_service_set_host; + +ALTER TABLE icinga_service_set + ADD CONSTRAINT icinga_service_set_host FOREIGN KEY (host_id) + REFERENCES icinga_host (id) + ON DELETE CASCADE + ON UPDATE CASCADE; + +ALTER TABLE icinga_service + DROP CONSTRAINT icinga_service_service_set; + +ALTER TABLE icinga_service + ADD CONSTRAINT icinga_service_service_set FOREIGN KEY (service_set_id) + REFERENCES icinga_service_set (id) + ON DELETE CASCADE + ON UPDATE CASCADE; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (124, NOW()); diff --git a/schema/pgsql.sql b/schema/pgsql.sql index 099b73fe..ccb801e0 100644 --- a/schema/pgsql.sql +++ b/schema/pgsql.sql @@ -682,7 +682,7 @@ CREATE TABLE icinga_service_set ( CONSTRAINT icinga_service_set_host FOREIGN KEY (host_id) REFERENCES icinga_host (id) - ON DELETE RESTRICT + ON DELETE CASCADE ON UPDATE CASCADE ); @@ -758,7 +758,7 @@ CREATE TABLE icinga_service ( CONSTRAINT icinga_service_service_set FOREIGN KEY (service_set_id) REFERENCES icinga_service_set (id) - ON DELETE RESTRICT + ON DELETE CASCADE ON UPDATE CASCADE ); @@ -1593,4 +1593,4 @@ CREATE UNIQUE INDEX notification_inheritance ON icinga_notification_inheritance INSERT INTO director_schema_migration (schema_version, migration_time) - VALUES (123, NOW()); + VALUES (124, NOW());