Skip to content

Commit

Permalink
pgsql schema: Introduce id' and group_id'
Browse files Browse the repository at this point in the history
Required to ensure referential integrity when renaming groups.

refs #8826
  • Loading branch information
Johannes Meyer committed May 28, 2015
1 parent 1950ddc commit 1c6ded9
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions etc/schema/pgsql.schema.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */

CREATE TABLE "icingaweb_group" (
"id" serial,
"name" character varying(64) NOT NULL,
"parent" character varying(64) NULL DEFAULT NULL,
"ctime" timestamp NULL DEFAULT NULL,
Expand All @@ -10,7 +11,7 @@ CREATE TABLE "icingaweb_group" (
ALTER TABLE ONLY "icingaweb_group"
ADD CONSTRAINT pk_icingaweb_group
PRIMARY KEY (
"name"
"id"
);

CREATE UNIQUE INDEX idx_icingaweb_group
Expand All @@ -20,23 +21,25 @@ CREATE UNIQUE INDEX idx_icingaweb_group
);

CREATE TABLE "icingaweb_group_membership" (
"group_name" character varying(64) NOT NULL,
"group_id" int NOT NULL,
"username" character varying(64) NOT NULL,
"ctime" timestamp NULL DEFAULT NULL,
"mtime" timestamp NULL DEFAULT NULL
);

ALTER TABLE ONLY "icingaweb_group_membership"
ADD CONSTRAINT pk_icingaweb_group_membership
PRIMARY KEY (
"group_name",
"username"
FOREIGN KEY (
"group_id"
)
REFERENCES "icingaweb_group" (
"id"
);

CREATE UNIQUE INDEX idx_icingaweb_group_membership
ON "icingaweb_group_membership"
USING btree (
lower((group_name)::text),
group_id,
lower((username)::text)
);

Expand Down

0 comments on commit 1c6ded9

Please sign in to comment.