Notification: add fields support

fixes #12642
This commit is contained in:
Thomas Gelf 2016-10-13 14:34:25 +00:00
parent 71b3459540
commit cf4dccc817
6 changed files with 108 additions and 2 deletions

View File

@ -29,6 +29,8 @@ class IcingaNotification extends IcingaObject
protected $supportsCustomVars = true;
protected $supportsFields = true;
protected $supportsImports = true;
protected $supportsApplyRules = true;

View File

@ -0,0 +1,18 @@
<?php
namespace Icinga\Module\Director\Objects;
use Icinga\Module\Director\Data\Db\DbObject;
class IcingaNotificationField extends DbObject
{
protected $keyName = array('notification_id', 'datafield_id');
protected $table = 'icinga_notification_field';
protected $defaultProperties = array(
'notification_id' => null,
'datafield_id' => null,
'is_required' => null
);
}

View File

@ -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());

View File

@ -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;

View File

@ -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());

View File

@ -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());