pgsql schema: Introduce `id' and `group_id'
Required to ensure referential integrity when renaming groups. refs #8826
This commit is contained in:
parent
1950ddcbd6
commit
1c6ded9324
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -20,7 +21,7 @@ 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
|
||||
|
@ -28,15 +29,17 @@ CREATE TABLE "icingaweb_group_membership" (
|
|||
|
||||
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)
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in New Issue