From 7aba7fdb5fae5da88ea70b19e0dee49480fcef49 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Tue, 23 Jun 2015 17:15:30 +0200 Subject: [PATCH] pgsql.sql: fix missnamed fkey column --- schema/pgsql-changes/upgrade_1.sql | 13 +++++++++++++ schema/pgsql.sql | 11 ++++------- 2 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 schema/pgsql-changes/upgrade_1.sql diff --git a/schema/pgsql-changes/upgrade_1.sql b/schema/pgsql-changes/upgrade_1.sql new file mode 100644 index 00000000..11921c7d --- /dev/null +++ b/schema/pgsql-changes/upgrade_1.sql @@ -0,0 +1,13 @@ +ALTER TABLE icinga_hostgroup_parent DROP CONSTRAINT icinga_hostgroup_parent_parent; +ALTER TABLE icinga_hostgroup_parent ADD CONSTRAINT icinga_hostgroup_parent_parent + FOREIGN KEY (parent_hostgroup_id) + REFERENCES icinga_hostgroup (id) + ON DELETE RESTRICT + ON UPDATE CASCADE; + +ALTER TABLE icinga_usergroup_parent DROP CONSTRAINT icinga_usergroup_parent_parent; +ALTER TABLE icinga_usergroup_parent ADD CONSTRAINT icinga_usergroup_parent_parent + FOREIGN KEY (parent_usergroup_id) + REFERENCES icinga_usergroup (id) + ON DELETE RESTRICT + ON UPDATE CASCADE; \ No newline at end of file diff --git a/schema/pgsql.sql b/schema/pgsql.sql index 85a91779..ad465d87 100644 --- a/schema/pgsql.sql +++ b/schema/pgsql.sql @@ -451,7 +451,6 @@ CREATE TABLE icinga_host_inheritance ( ); CREATE UNIQUE INDEX host_inheritance_unique_order ON icinga_host_inheritance (host_id, weight); --- TODO: drop one of them? CREATE INDEX host_inheritance_host ON icinga_host_inheritance (host_id); CREATE INDEX host_inheritance_host_parent ON icinga_host_inheritance (parent_host_id); @@ -673,15 +672,14 @@ CREATE TABLE icinga_hostgroup_parent ( ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT icinga_hostgroup_parent_parent - FOREIGN KEY (hostgroup_id) + FOREIGN KEY (parent_hostgroup_id) REFERENCES icinga_hostgroup (id) ON DELETE RESTRICT ON UPDATE CASCADE ); CREATE INDEX hostgroup_parent_hostgroup ON icinga_hostgroup_parent (hostgroup_id); --- TODO: drop one of them? -CREATE INDEX hostgroup_parent_parent ON icinga_hostgroup_parent (hostgroup_id); +CREATE INDEX hostgroup_parent_parent ON icinga_hostgroup_parent (parent_hostgroup_id); -- -- Table structure for table icinga_user @@ -821,15 +819,14 @@ CREATE TABLE icinga_usergroup_parent ( ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT icinga_usergroup_parent_parent - FOREIGN KEY (usergroup_id) + FOREIGN KEY (parent_usergroup_id) REFERENCES icinga_usergroup (id) ON DELETE RESTRICT ON UPDATE CASCADE ); CREATE INDEX usergroup_parent_usergroup ON icinga_usergroup_parent (usergroup_id); --- TODO: drop one of them? -CREATE INDEX usergroup_parent_parent ON icinga_usergroup_parent (usergroup_id); +CREATE INDEX usergroup_parent_parent ON icinga_usergroup_parent (parent_usergroup_id); -- -- TODO: unfinished: see mysql.sql schema from sync_*