schema/mysql: delete services on host deletion

We would otherwise create host-less service-aliens
This commit is contained in:
Thomas Gelf 2016-02-29 15:41:55 +01:00
parent 5427df52e8
commit 83d2047a23
2 changed files with 17 additions and 3 deletions

View File

@ -0,0 +1,14 @@
ALTER TABLE icinga_service
DROP FOREIGN KEY icinga_host;
ALTER TABLE icinga_service
ADD CONSTRAINT icinga_service_host
FOREIGN KEY host (host_id)
REFERENCES icinga_host (id)
ON DELETE CASCADE
ON UPDATE CASCADE;
INSERT INTO director_schema_migration
SET migration_time = NOW(),
schema_version = 74;

View File

@ -525,10 +525,10 @@ CREATE TABLE icinga_service (
PRIMARY KEY (id),
-- UNIQUE INDEX object_name (object_name, zone_id),
UNIQUE KEY object_key (object_name, host_id),
CONSTRAINT icinga_host
CONSTRAINT icinga_service_host
FOREIGN KEY host (host_id)
REFERENCES icinga_host (id)
ON DELETE SET NULL
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT icinga_service_zone
FOREIGN KEY zone (zone_id)
@ -1112,4 +1112,4 @@ CREATE TABLE sync_run (
INSERT INTO director_schema_migration
SET migration_time = NOW(),
schema_version = 73;
schema_version = 74;