diff --git a/schema/mysql-migrations/upgrade_131.sql b/schema/mysql-migrations/upgrade_131.sql new file mode 100644 index 00000000..282e0608 --- /dev/null +++ b/schema/mysql-migrations/upgrade_131.sql @@ -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()); diff --git a/schema/mysql.sql b/schema/mysql.sql index d47066aa..ac87e29f 100644 --- a/schema/mysql.sql +++ b/schema/mysql.sql @@ -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()); diff --git a/schema/pgsql-migrations/upgrade_131.sql b/schema/pgsql-migrations/upgrade_131.sql new file mode 100644 index 00000000..37fc5b74 --- /dev/null +++ b/schema/pgsql-migrations/upgrade_131.sql @@ -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()); diff --git a/schema/pgsql.sql b/schema/pgsql.sql index aad19441..ce22777b 100644 --- a/schema/pgsql.sql +++ b/schema/pgsql.sql @@ -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());