schema: relax choice constraint for delete

This commit is contained in:
Thomas Gelf 2017-07-05 06:06:45 +02:00
parent ceebe08ecd
commit 303b8776a2
4 changed files with 44 additions and 6 deletions

View File

@ -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());

View File

@ -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());

View File

@ -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());

View File

@ -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());