diff --git a/library/Director/Objects/IcingaTemplateChoice.php b/library/Director/Objects/IcingaTemplateChoice.php index 77b1aa7d..484c8db0 100644 --- a/library/Director/Objects/IcingaTemplateChoice.php +++ b/library/Director/Objects/IcingaTemplateChoice.php @@ -14,6 +14,8 @@ class IcingaTemplateChoice extends IcingaObject 'description' => null, 'min_required' => 0, 'max_allowed' => 1, + 'required_template_id' => null, + 'allowed_roles' => null, ]; private $choices; diff --git a/library/Director/Objects/IcingaTemplateChoiceHost.php b/library/Director/Objects/IcingaTemplateChoiceHost.php index 9112fbc2..10ddedd6 100644 --- a/library/Director/Objects/IcingaTemplateChoiceHost.php +++ b/library/Director/Objects/IcingaTemplateChoiceHost.php @@ -7,4 +7,8 @@ class IcingaTemplateChoiceHost extends IcingaTemplateChoice protected $table = 'icinga_host_template_choice'; protected $objectTable = 'icinga_host'; + + protected $relations = array( + 'required_template' => 'IcingaHost', + ); } diff --git a/library/Director/Objects/IcingaTemplateChoiceService.php b/library/Director/Objects/IcingaTemplateChoiceService.php index ff74d426..5cdb43e2 100644 --- a/library/Director/Objects/IcingaTemplateChoiceService.php +++ b/library/Director/Objects/IcingaTemplateChoiceService.php @@ -7,4 +7,8 @@ class IcingaTemplateChoiceService extends IcingaTemplateChoice protected $table = 'icinga_service_template_choice'; protected $objectTable = 'icinga_service'; + + protected $relations = array( + 'required_template' => 'IcingaService', + ); } diff --git a/schema/mysql-migrations/upgrade_143.sql b/schema/mysql-migrations/upgrade_143.sql new file mode 100644 index 00000000..7d07385b --- /dev/null +++ b/schema/mysql-migrations/upgrade_143.sql @@ -0,0 +1,21 @@ +ALTER TABLE icinga_host_template_choice + ADD COLUMN required_template_id INT(10) UNSIGNED DEFAULT NULL, + ADD COLUMN allowed_roles VARCHAR(255) DEFAULT NULL, + ADD CONSTRAINT host_template_choice_required_template + FOREIGN KEY required_template (required_template_id) + REFERENCES icinga_host (id) + ON DELETE RESTRICT + ON UPDATE CASCADE; + +ALTER TABLE icinga_service_template_choice + ADD COLUMN required_template_id INT(10) UNSIGNED DEFAULT NULL, + ADD COLUMN allowed_roles VARCHAR(255) DEFAULT NULL, + ADD CONSTRAINT service_template_choice_required_template + FOREIGN KEY required_template (required_template_id) + REFERENCES icinga_service (id) + ON DELETE RESTRICT + ON UPDATE CASCADE; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (143, NOW()); diff --git a/schema/mysql.sql b/schema/mysql.sql index 84e26c42..5f0887db 100644 --- a/schema/mysql.sql +++ b/schema/mysql.sql @@ -428,6 +428,13 @@ CREATE TABLE icinga_host_template_choice ( description TEXT DEFAULT NULL, min_required SMALLINT UNSIGNED NOT NULL DEFAULT 0, max_allowed SMALLINT UNSIGNED NOT NULL DEFAULT 1, + required_template_id INT(10) UNSIGNED DEFAULT NULL, + allowed_roles VARCHAR(255) DEFAULT NULL, + CONSTRAINT host_template_choice_required_template + FOREIGN KEY required_template (required_template_id) + REFERENCES icinga_host (id) + ON DELETE RESTRICT + ON UPDATE CASCADE, PRIMARY KEY (id), UNIQUE KEY (object_name) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -577,6 +584,13 @@ CREATE TABLE icinga_service_template_choice ( description TEXT DEFAULT NULL, min_required SMALLINT UNSIGNED NOT NULL DEFAULT 0, max_allowed SMALLINT UNSIGNED NOT NULL DEFAULT 1, + required_template_id INT(10) UNSIGNED DEFAULT NULL, + allowed_roles VARCHAR(255) DEFAULT NULL, + CONSTRAINT service_template_choice_required_template + FOREIGN KEY required_template (required_template_id) + REFERENCES icinga_service (id) + ON DELETE RESTRICT + ON UPDATE CASCADE, PRIMARY KEY (id), UNIQUE KEY (object_name) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -1563,4 +1577,4 @@ CREATE TABLE icinga_user_resolved_var ( INSERT INTO director_schema_migration (schema_version, migration_time) - VALUES (141, NOW()); + VALUES (143, NOW()); diff --git a/schema/pgsql-migrations/upgrade_143.sql b/schema/pgsql-migrations/upgrade_143.sql new file mode 100644 index 00000000..3c8e9c5e --- /dev/null +++ b/schema/pgsql-migrations/upgrade_143.sql @@ -0,0 +1,27 @@ +ALTER TABLE icinga_host_template_choice + ADD COLUMN required_template_id integer DEFAULT NULL, + ADD COLUMN allowed_roles character varying(255) DEFAULT NULL, + ADD CONSTRAINT host_template_choice_required_template + FOREIGN KEY (required_template_id) + REFERENCES icinga_host (id) + ON DELETE RESTRICT + ON UPDATE CASCADE; + +ALTER TABLE icinga_service_template_choice + ADD COLUMN required_template_id integer DEFAULT NULL, + ADD COLUMN allowed_roles character varying(255) DEFAULT NULL, + ADD CONSTRAINT service_template_choice_required_template + FOREIGN KEY (required_template_id) + REFERENCES icinga_service (id) + ON DELETE RESTRICT + ON UPDATE CASCADE; + +CREATE INDEX host_template_choice_required_template + ON icinga_host_template_choice (required_template_id); + +CREATE INDEX service_template_choice_required_template + ON icinga_service_template_choice (required_template_id); + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (143, NOW()); diff --git a/schema/pgsql.sql b/schema/pgsql.sql index 9e38e001..f227734b 100644 --- a/schema/pgsql.sql +++ b/schema/pgsql.sql @@ -551,10 +551,18 @@ CREATE TABLE icinga_host_template_choice ( description text DEFAULT NULL, min_required smallint NOT NULL DEFAULT 0, max_allowed smallint NOT NULL DEFAULT 1, + required_template_id integer DEFAULT NULL, + allowed_roles character varying(255) DEFAULT NULL, + CONSTRAINT host_template_choice_required_template + FOREIGN KEY (required_template_id) + REFERENCES icinga_host (id) + ON DELETE RESTRICT + ON UPDATE CASCADE, PRIMARY KEY (id) ); CREATE UNIQUE INDEX host_template_choice_object_name ON icinga_host_template_choice (object_name); +CREATE INDEX host_template_choice_required_template ON icinga_host_template_choice (required_template_id); CREATE TABLE icinga_host ( id serial, @@ -725,10 +733,18 @@ CREATE TABLE icinga_service_template_choice ( description text DEFAULT NULL, min_required smallint NOT NULL DEFAULT 0, max_allowed smallint NOT NULL DEFAULT 1, + required_template_id integer DEFAULT NULL, + allowed_roles character varying(255) DEFAULT NULL, + CONSTRAINT service_template_choice_required_template + FOREIGN KEY (required_template_id) + REFERENCES icinga_service (id) + ON DELETE RESTRICT + ON UPDATE CASCADE, PRIMARY KEY (id) ); CREATE UNIQUE INDEX service_template_choice_object_name ON icinga_service_template_choice (object_name); +CREATE INDEX service_template_choice_required_template ON icinga_service_template_choice (required_template_id); CREATE TABLE icinga_service ( @@ -1841,4 +1857,4 @@ CREATE INDEX user_resolved_var_schecksum ON icinga_user_resolved_var (checksum); INSERT INTO director_schema_migration (schema_version, migration_time) - VALUES (142, NOW()); + VALUES (143, NOW());