diff --git a/etc/schema/pgsql.schema.sql b/etc/schema/pgsql.schema.sql index 034d8288a..09ecb0b71 100644 --- a/etc/schema/pgsql.schema.sql +++ b/etc/schema/pgsql.schema.sql @@ -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) );