diff --git a/schema/mysql-migrations/upgrade_134.sql b/schema/mysql-migrations/upgrade_134.sql new file mode 100644 index 00000000..b652e5b4 --- /dev/null +++ b/schema/mysql-migrations/upgrade_134.sql @@ -0,0 +1,19 @@ +ALTER TABLE icinga_host + DROP FOREIGN KEY icinga_host_template_choice, + ADD CONSTRAINT icinga_host_template_choice_v2 + FOREIGN KEY template_choice (template_choice_id) + REFERENCES icinga_host_template_choice (id) + ON DELETE SET NULL + ON UPDATE CASCADE; + +ALTER TABLE icinga_service + DROP FOREIGN KEY icinga_service_template_choice, + ADD CONSTRAINT icinga_service_template_choice_v2 + FOREIGN KEY template_choice (template_choice_id) + REFERENCES icinga_service_template_choice (id) + ON DELETE SET NULL + ON UPDATE CASCADE; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (134, NOW()); diff --git a/schema/mysql.sql b/schema/mysql.sql index cdc6c314..a07008aa 100644 --- a/schema/mysql.sql +++ b/schema/mysql.sql @@ -497,7 +497,7 @@ CREATE TABLE icinga_host ( CONSTRAINT icinga_host_template_choice FOREIGN KEY choice (template_choice_id) REFERENCES icinga_host_template_choice (id) - ON DELETE RESTRICT + ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -653,7 +653,7 @@ CREATE TABLE icinga_service ( CONSTRAINT icinga_service_template_choice FOREIGN KEY choice (template_choice_id) REFERENCES icinga_service_template_choice (id) - ON DELETE RESTRICT + ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -1556,4 +1556,4 @@ CREATE TABLE icinga_user_resolved_var ( INSERT INTO director_schema_migration (schema_version, migration_time) - VALUES (133, NOW()); + VALUES (134, NOW()); diff --git a/schema/pgsql-migrations/upgrade_134.sql b/schema/pgsql-migrations/upgrade_134.sql new file mode 100644 index 00000000..d08510ff --- /dev/null +++ b/schema/pgsql-migrations/upgrade_134.sql @@ -0,0 +1,19 @@ +ALTER TABLE icinga_host + DROP CONSTRAINT icinga_host_template_choice, + ADD CONSTRAINT icinga_host_template_choice_v2 + FOREIGN KEY (template_choice_id) + REFERENCES icinga_host_template_choice (id) + ON DELETE SET NULL + ON UPDATE CASCADE; + +ALTER TABLE icinga_service + DROP CONSTRAINT icinga_service_template_choice, + ADD CONSTRAINT icinga_service_template_choice_v2 + FOREIGN KEY (template_choice_id) + REFERENCES icinga_service_template_choice (id) + ON DELETE SET NULL + ON UPDATE CASCADE; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (134, NOW()); diff --git a/schema/pgsql.sql b/schema/pgsql.sql index f1b60d53..ab622922 100644 --- a/schema/pgsql.sql +++ b/schema/pgsql.sql @@ -618,7 +618,7 @@ CREATE TABLE icinga_host ( CONSTRAINT icinga_host_template_choice FOREIGN KEY (template_choice_id) REFERENCES icinga_host_template_choice (id) - ON DELETE RESTRICT + ON DELETE SET NULL ON UPDATE CASCADE ); @@ -803,7 +803,7 @@ CREATE TABLE icinga_service ( CONSTRAINT icinga_service_template_choice FOREIGN KEY (template_choice_id) REFERENCES icinga_service_template_choice (id) - ON DELETE RESTRICT + ON DELETE SET NULL ON UPDATE CASCADE ); @@ -1833,4 +1833,4 @@ CREATE INDEX user_resolved_var_schecksum ON icinga_user_resolved_var (checksum); INSERT INTO director_schema_migration (schema_version, migration_time) - VALUES (133, NOW()); + VALUES (134, NOW());