diff --git a/library/Director/Objects/IcingaNotification.php b/library/Director/Objects/IcingaNotification.php index 37e74f1a..c5c5cb5a 100644 --- a/library/Director/Objects/IcingaNotification.php +++ b/library/Director/Objects/IcingaNotification.php @@ -29,6 +29,8 @@ class IcingaNotification extends IcingaObject protected $supportsCustomVars = true; + protected $supportsFields = true; + protected $supportsImports = true; protected $supportsApplyRules = true; diff --git a/library/Director/Objects/IcingaNotificationField.php b/library/Director/Objects/IcingaNotificationField.php new file mode 100644 index 00000000..7e3e912e --- /dev/null +++ b/library/Director/Objects/IcingaNotificationField.php @@ -0,0 +1,18 @@ + null, + 'datafield_id' => null, + 'is_required' => null + ); +} diff --git a/schema/mysql-migrations/upgrade_117.sql b/schema/mysql-migrations/upgrade_117.sql new file mode 100644 index 00000000..e0ab4f30 --- /dev/null +++ b/schema/mysql-migrations/upgrade_117.sql @@ -0,0 +1,20 @@ +CREATE TABLE icinga_notification_field ( + notification_id INT(10) UNSIGNED NOT NULL COMMENT 'Makes only sense for templates', + datafield_id INT(10) UNSIGNED NOT NULL, + is_required ENUM('y', 'n') NOT NULL, + PRIMARY KEY (notification_id, datafield_id), + CONSTRAINT icinga_notification_field_notification + FOREIGN KEY notification (notification_id) + REFERENCES icinga_notification (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT icinga_notification_field_datafield + FOREIGN KEY datafield(datafield_id) + REFERENCES director_datafield (id) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (117, NOW()); diff --git a/schema/mysql.sql b/schema/mysql.sql index e9723580..9e37ed61 100644 --- a/schema/mysql.sql +++ b/schema/mysql.sql @@ -1089,6 +1089,23 @@ CREATE TABLE icinga_notification_var ( ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE icinga_notification_field ( + notification_id INT(10) UNSIGNED NOT NULL COMMENT 'Makes only sense for templates', + datafield_id INT(10) UNSIGNED NOT NULL, + is_required ENUM('y', 'n') NOT NULL, + PRIMARY KEY (notification_id, datafield_id), + CONSTRAINT icinga_notification_field_notification + FOREIGN KEY notification (notification_id) + REFERENCES icinga_notification (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT icinga_notification_field_datafield + FOREIGN KEY datafield(datafield_id) + REFERENCES director_datafield (id) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + CREATE TABLE icinga_notification_inheritance ( notification_id INT(10) UNSIGNED NOT NULL, parent_notification_id INT(10) UNSIGNED NOT NULL, @@ -1398,4 +1415,4 @@ CREATE TABLE sync_run ( INSERT INTO director_schema_migration SET migration_time = NOW(), - schema_version = 116; + schema_version = 117; diff --git a/schema/pgsql-migrations/upgrade_117.sql b/schema/pgsql-migrations/upgrade_117.sql new file mode 100644 index 00000000..6f3820fb --- /dev/null +++ b/schema/pgsql-migrations/upgrade_117.sql @@ -0,0 +1,26 @@ +CREATE TABLE icinga_notification_field ( + notification_id integer NOT NULL, + datafield_id integer NOT NULL, + is_required enum_boolean NOT NULL, + PRIMARY KEY (notification_id, datafield_id), + CONSTRAINT icinga_notification_field_notification + FOREIGN KEY (notification_id) + REFERENCES icinga_notification (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT icinga_notification_field_datafield + FOREIGN KEY (datafield_id) + REFERENCES director_datafield (id) + ON DELETE CASCADE + ON UPDATE CASCADE +); + +CREATE UNIQUE INDEX notification_field_key ON icinga_notification_field (notification_id, datafield_id); +CREATE INDEX notification_field_notification ON icinga_notification_field (notification_id); +CREATE INDEX notification_field_datafield ON icinga_notification_field (datafield_id); +COMMENT ON COLUMN icinga_notification_field.notification_id IS 'Makes only sense for templates'; + + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (117, NOW()); diff --git a/schema/pgsql.sql b/schema/pgsql.sql index 6e050c19..7e72201d 100644 --- a/schema/pgsql.sql +++ b/schema/pgsql.sql @@ -1601,6 +1601,29 @@ CREATE TABLE icinga_notification_var ( CREATE UNIQUE INDEX notification_var_search_idx ON icinga_notification_var (varname); +CREATE TABLE icinga_notification_field ( + notification_id integer NOT NULL, + datafield_id integer NOT NULL, + is_required enum_boolean NOT NULL, + PRIMARY KEY (notification_id, datafield_id), + CONSTRAINT icinga_notification_field_notification + FOREIGN KEY (notification_id) + REFERENCES icinga_notification (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT icinga_notification_field_datafield + FOREIGN KEY (datafield_id) + REFERENCES director_datafield (id) + ON DELETE CASCADE + ON UPDATE CASCADE +); + +CREATE UNIQUE INDEX notification_field_key ON icinga_notification_field (notification_id, datafield_id); +CREATE INDEX notification_field_notification ON icinga_notification_field (notification_id); +CREATE INDEX notification_field_datafield ON icinga_notification_field (datafield_id); +COMMENT ON COLUMN icinga_notification_field.notification_id IS 'Makes only sense for templates'; + + CREATE TABLE icinga_notification_inheritance ( notification_id integer NOT NULL, parent_notification_id integer NOT NULL, @@ -1623,4 +1646,4 @@ CREATE UNIQUE INDEX notification_inheritance ON icinga_notification_inheritance INSERT INTO director_schema_migration (schema_version, migration_time) - VALUES (116, NOW()); + VALUES (117, NOW());