diff --git a/dmp-db-scema/DataManagementPlanDB.sql b/dmp-db-scema/DataManagementPlanDB.sql index 9a97eae62..56fdc5e1d 100644 --- a/dmp-db-scema/DataManagementPlanDB.sql +++ b/dmp-db-scema/DataManagementPlanDB.sql @@ -447,12 +447,13 @@ ALTER TABLE ONLY "DatasetService" ADD CONSTRAINT "DatasetServiceServiceReference" FOREIGN KEY ("Service") REFERENCES "Service"("ID"); +DROP table if exists "UserDMP"; DROP table if exists "UserInfo"; +DROP table if exists "UserAuth"; CREATE TABLE "UserInfo" ( - "autoid" uuid DEFAULT uuid_generate_v4() NOT NULL, - "identification" character varying(500) NOT NULL, - "email" character varying(250) NOT NULL, + "id" uuid DEFAULT uuid_generate_v4() UNIQUE NOT NULL, + "email" character varying(250) UNIQUE NOT NULL, "authorization_level" smallint NOT NULL, "usertype" smallint NOT NULL, "authentication" uuid, @@ -461,15 +462,13 @@ CREATE TABLE "UserInfo" ( "created" timestamp, "lastloggedin" timestamp, "additionalinfo" xml, - PRIMARY KEY (identification, email) + PRIMARY KEY (id) ); COMMENT ON COLUMN "UserInfo"."authorization_level" IS 'This stores the authorization level of the user: 0 admin, 1 user, being able to be extended furthermore'; COMMENT ON COLUMN "UserInfo"."usertype" IS 'This stores the type of user: 0 -> internal, 1 external'; -DROP table if exists "UserAuth"; - CREATE TABLE "UserAuth" ( "id" uuid DEFAULT uuid_generate_v4() NOT NULL UNIQUE, "username" character varying(200) NOT NULL, @@ -483,8 +482,21 @@ ALTER TABLE "UserInfo" ADD CONSTRAINT fkey_userinfo_userauth FOREIGN KEY ("authe COMMENT ON COLUMN "UserAuth"."password" IS 'This field stores a password hash'; + +create table "UserDMP" ( + "id" uuid DEFAULT uuid_generate_v4() NOT NULL, + "user" uuid NOT NULL, + "dmp" uuid NOT NUll, + "role" integer +); + +ALTER TABLE "UserDMP" ADD CONSTRAINT fkey_userdmp_user FOREIGN KEY ("user") REFERENCES "UserInfo"("id"); +ALTER TABLE "UserDMP" ADD CONSTRAINT fkey_userdmp_dmp FOREIGN KEY ("dmp") REFERENCES "DMP"("ID"); + + ALTER TABLE "UserInfo" OWNER TO dmptool; ALTER TABLE "UserAuth" OWNER TO dmptool; +ALTER TABLE "UserDMP" OWNER TO dmptool;