schema: add tables for notification user(group)s

This commit is contained in:
Thomas Gelf 2016-03-15 22:23:21 +01:00
parent 5e80516f6d
commit a3c089e6c6
4 changed files with 137 additions and 2 deletions

View File

@ -0,0 +1,35 @@
CREATE TABLE icinga_notification_user (
notification_id INT(10) UNSIGNED NOT NULL,
user_id INT(10) UNSIGNED NOT NULL,
PRIMARY KEY (notification_id, user_id),
CONSTRAINT icinga_notification_user_user
FOREIGN KEY user (user_id)
REFERENCES icinga_user (id)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT icinga_notification_user_notification
FOREIGN KEY notification (notification_id)
REFERENCES icinga_notification (id)
ON DELETE CASCADE
ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE icinga_notification_usergroup (
notification_id INT(10) UNSIGNED NOT NULL,
usergroup_id INT(10) UNSIGNED NOT NULL,
PRIMARY KEY (notification_id, usergroup_id),
CONSTRAINT icinga_notification_usergroup_usergroup
FOREIGN KEY usergroup (usergroup_id)
REFERENCES icinga_usergroup (id)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT icinga_notification_usergroup_notification
FOREIGN KEY notification (notification_id)
REFERENCES icinga_notification (id)
ON DELETE CASCADE
ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO director_schema_migration
(schema_version, migration_time)
VALUES (86, NOW());

View File

@ -1041,6 +1041,38 @@ CREATE TABLE icinga_notification_assignment (
ON UPDATE CASCADE
) ENGINE=InnoDB;
CREATE TABLE icinga_notification_user (
notification_id INT(10) UNSIGNED NOT NULL,
user_id INT(10) UNSIGNED NOT NULL,
PRIMARY KEY (notification_id, user_id),
CONSTRAINT icinga_notification_user_user
FOREIGN KEY user (user_id)
REFERENCES icinga_user (id)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT icinga_notification_user_notification
FOREIGN KEY notification (notification_id)
REFERENCES icinga_notification (id)
ON DELETE CASCADE
ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE icinga_notification_usergroup (
notification_id INT(10) UNSIGNED NOT NULL,
usergroup_id INT(10) UNSIGNED NOT NULL,
PRIMARY KEY (notification_id, usergroup_id),
CONSTRAINT icinga_notification_usergroup_usergroup
FOREIGN KEY usergroup (usergroup_id)
REFERENCES icinga_usergroup (id)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT icinga_notification_usergroup_notification
FOREIGN KEY notification (notification_id)
REFERENCES icinga_notification (id)
ON DELETE CASCADE
ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE import_source (
id INT(10) UNSIGNED AUTO_INCREMENT NOT NULL,
source_name VARCHAR(64) NOT NULL,
@ -1225,4 +1257,4 @@ CREATE TABLE sync_run (
INSERT INTO director_schema_migration
SET migration_time = NOW(),
schema_version = 85;
schema_version = 86;

View File

@ -0,0 +1,35 @@
CREATE TABLE icinga_notification_user (
notification_id integer NOT NULL,
user_id integer NOT NULL,
PRIMARY KEY (notification_id, user_id),
CONSTRAINT icinga_notification_user_user
FOREIGN KEY (user_id)
REFERENCES icinga_user (id)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT icinga_notification_user_notification
FOREIGN KEY (notification_id)
REFERENCES icinga_notification (id)
ON DELETE CASCADE
ON UPDATE CASCADE
);
CREATE TABLE icinga_notification_usergroup (
notification_id integer NOT NULL,
usergroup_id integer NOT NULL,
PRIMARY KEY (notification_id, usergroup_id),
CONSTRAINT icinga_notification_usergroup_usergroup
FOREIGN KEY (usergroup_id)
REFERENCES icinga_usergroup (id)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT icinga_notification_usergroup_notification
FOREIGN KEY (notification_id)
REFERENCES icinga_notification (id)
ON DELETE CASCADE
ON UPDATE CASCADE
);
INSERT INTO director_schema_migration
(schema_version, migration_time)
VALUES (86, NOW());

View File

@ -1165,6 +1165,39 @@ CREATE TABLE icinga_notification_assignment (
);
CREATE TABLE icinga_notification_user (
notification_id integer NOT NULL,
user_id integer NOT NULL,
PRIMARY KEY (notification_id, user_id),
CONSTRAINT icinga_notification_user_user
FOREIGN KEY (user_id)
REFERENCES icinga_user (id)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT icinga_notification_user_notification
FOREIGN KEY (notification_id)
REFERENCES icinga_notification (id)
ON DELETE CASCADE
ON UPDATE CASCADE
);
CREATE TABLE icinga_notification_usergroup (
notification_id integer NOT NULL,
usergroup_id integer NOT NULL,
PRIMARY KEY (notification_id, usergroup_id),
CONSTRAINT icinga_notification_usergroup_usergroup
FOREIGN KEY (usergroup_id)
REFERENCES icinga_usergroup (id)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT icinga_notification_usergroup_notification
FOREIGN KEY (notification_id)
REFERENCES icinga_notification (id)
ON DELETE CASCADE
ON UPDATE CASCADE
);
CREATE TABLE import_source (
id serial,
source_name character varying(64) NOT NULL,
@ -1437,4 +1470,4 @@ CREATE UNIQUE INDEX notification_inheritance ON icinga_notification_inheritance
-- set current schema version
INSERT INTO director_schema_migration
(schema_version, migration_time)
VALUES (85, NOW());
VALUES (86, NOW());