From a3c089e6c6feca1dcda5b4125717804a7a0cb0e6 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 15 Mar 2016 22:23:21 +0100 Subject: [PATCH] schema: add tables for notification user(group)s --- schema/mysql-migrations/upgrade_86.sql | 35 ++++++++++++++++++++++++++ schema/mysql.sql | 34 ++++++++++++++++++++++++- schema/pgsql-migrations/upgrade_86.sql | 35 ++++++++++++++++++++++++++ schema/pgsql.sql | 35 +++++++++++++++++++++++++- 4 files changed, 137 insertions(+), 2 deletions(-) create mode 100644 schema/mysql-migrations/upgrade_86.sql create mode 100644 schema/pgsql-migrations/upgrade_86.sql diff --git a/schema/mysql-migrations/upgrade_86.sql b/schema/mysql-migrations/upgrade_86.sql new file mode 100644 index 00000000..58b81c0a --- /dev/null +++ b/schema/mysql-migrations/upgrade_86.sql @@ -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()); diff --git a/schema/mysql.sql b/schema/mysql.sql index 43e5f3c3..efd68afe 100644 --- a/schema/mysql.sql +++ b/schema/mysql.sql @@ -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; diff --git a/schema/pgsql-migrations/upgrade_86.sql b/schema/pgsql-migrations/upgrade_86.sql new file mode 100644 index 00000000..9672f3e2 --- /dev/null +++ b/schema/pgsql-migrations/upgrade_86.sql @@ -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()); diff --git a/schema/pgsql.sql b/schema/pgsql.sql index 1b215630..414f0523 100644 --- a/schema/pgsql.sql +++ b/schema/pgsql.sql @@ -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());