summaryrefslogtreecommitdiffstats
path: root/schema/pgsql-legacy-changes/upgrade-10.sql
diff options
context:
space:
mode:
Diffstat (limited to 'schema/pgsql-legacy-changes/upgrade-10.sql')
-rw-r--r--schema/pgsql-legacy-changes/upgrade-10.sql20
1 files changed, 20 insertions, 0 deletions
diff --git a/schema/pgsql-legacy-changes/upgrade-10.sql b/schema/pgsql-legacy-changes/upgrade-10.sql
new file mode 100644
index 0000000..4fd3cc1
--- /dev/null
+++ b/schema/pgsql-legacy-changes/upgrade-10.sql
@@ -0,0 +1,20 @@
+CREATE TABLE icinga_usergroup_inheritance (
+ usergroup_id integer NOT NULL,
+ parent_usergroup_id integer NOT NULL,
+ weight integer DEFAULT NULL,
+ PRIMARY KEY (usergroup_id, parent_usergroup_id),
+ CONSTRAINT icinga_usergroup_inheritance_usergroup
+ FOREIGN KEY (usergroup_id)
+ REFERENCES icinga_usergroup (id)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE,
+ CONSTRAINT icinga_usergroup_inheritance_parent_usergroup
+ FOREIGN KEY (parent_usergroup_id)
+ REFERENCES icinga_usergroup (id)
+ ON DELETE RESTRICT
+ ON UPDATE CASCADE
+);
+
+CREATE UNIQUE INDEX usergroup_inheritance_unique_order ON icinga_usergroup_inheritance (usergroup_id, weight);
+CREATE INDEX usergroup_inheritance_usergroup ON icinga_usergroup_inheritance (usergroup_id);
+CREATE INDEX usergroup_inheritance_usergroup_parent ON icinga_usergroup_inheritance (parent_usergroup_id);