schema: add resolved hostgroup member tables

refs #832
This commit is contained in:
Thomas Gelf 2017-03-14 08:36:57 +01:00
parent 56af88ee3f
commit 46a9b2574b
4 changed files with 79 additions and 2 deletions

View File

@ -0,0 +1,19 @@
CREATE TABLE icinga_hostgroup_host_resolved (
hostgroup_id INT(10) UNSIGNED NOT NULL,
host_id INT(10) UNSIGNED NOT NULL,
PRIMARY KEY (hostgroup_id, host_id),
CONSTRAINT icinga_hostgroup_host_resolved_host
FOREIGN KEY host (host_id)
REFERENCES icinga_host (id)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT icinga_hostgroup_host_resolved_hostgroup
FOREIGN KEY hostgroup (hostgroup_id)
REFERENCES icinga_hostgroup (id)
ON DELETE CASCADE
ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO director_schema_migration
(schema_version, migration_time)
VALUES (131, NOW());

View File

@ -820,6 +820,22 @@ CREATE TABLE icinga_hostgroup_host (
ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE icinga_hostgroup_host_resolved (
hostgroup_id INT(10) UNSIGNED NOT NULL,
host_id INT(10) UNSIGNED NOT NULL,
PRIMARY KEY (hostgroup_id, host_id),
CONSTRAINT icinga_hostgroup_host_resolved_host
FOREIGN KEY host (host_id)
REFERENCES icinga_host (id)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT icinga_hostgroup_host_resolved_hostgroup
FOREIGN KEY hostgroup (hostgroup_id)
REFERENCES icinga_hostgroup (id)
ON DELETE CASCADE
ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE icinga_hostgroup_parent (
hostgroup_id INT(10) UNSIGNED NOT NULL,
parent_hostgroup_id INT(10) UNSIGNED NOT NULL,
@ -1508,4 +1524,4 @@ CREATE TABLE icinga_user_resolved_var (
INSERT INTO director_schema_migration
(schema_version, migration_time)
VALUES (130, NOW());
VALUES (131, NOW());

View File

@ -0,0 +1,22 @@
CREATE TABLE icinga_hostgroup_host_resolved (
hostgroup_id integer NOT NULL,
host_id integer NOT NULL,
PRIMARY KEY (hostgroup_id, host_id),
CONSTRAINT icinga_hostgroup_host_resolved_host
FOREIGN KEY (host_id)
REFERENCES icinga_host (id)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT icinga_hostgroup_host_resolved_hostgroup
FOREIGN KEY (hostgroup_id)
REFERENCES icinga_hostgroup (id)
ON DELETE CASCADE
ON UPDATE CASCADE
);
CREATE INDEX hostgroup_host_resolved_host ON icinga_hostgroup_host_resolved (host_id);
CREATE INDEX hostgroup_host_resolved_hostgroup ON icinga_hostgroup_host_resolved (hostgroup_id);
INSERT INTO director_schema_migration
(schema_version, migration_time)
VALUES (131, NOW());

View File

@ -1016,6 +1016,26 @@ CREATE INDEX hostgroup_host_host ON icinga_hostgroup_host (host_id);
CREATE INDEX hostgroup_host_hostgroup ON icinga_hostgroup_host (hostgroup_id);
CREATE TABLE icinga_hostgroup_host_resolved (
hostgroup_id integer NOT NULL,
host_id integer NOT NULL,
PRIMARY KEY (hostgroup_id, host_id),
CONSTRAINT icinga_hostgroup_host_resolved_host
FOREIGN KEY (host_id)
REFERENCES icinga_host (id)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT icinga_hostgroup_host_resolved_hostgroup
FOREIGN KEY (hostgroup_id)
REFERENCES icinga_hostgroup (id)
ON DELETE CASCADE
ON UPDATE CASCADE
);
CREATE INDEX hostgroup_host_resolved_host ON icinga_hostgroup_host_resolved (host_id);
CREATE INDEX hostgroup_host_resolved_hostgroup ON icinga_hostgroup_host_resolved (hostgroup_id);
CREATE TABLE icinga_hostgroup_parent (
hostgroup_id integer NOT NULL,
parent_hostgroup_id integer NOT NULL,
@ -1775,4 +1795,4 @@ CREATE INDEX user_resolved_var_schecksum ON icinga_user_resolved_var (checksum);
INSERT INTO director_schema_migration
(schema_version, migration_time)
VALUES (128, NOW());
VALUES (131, NOW());