diff --git a/dmp-backend/web/src/main/resources/config/application.properties b/dmp-backend/web/src/main/resources/config/application.properties index 229e7ed48..84ae244b3 100644 --- a/dmp-backend/web/src/main/resources/config/application.properties +++ b/dmp-backend/web/src/main/resources/config/application.properties @@ -2,7 +2,7 @@ server.port=8081 server.tomcat.max-threads = 20 server.tomcat.max-connections = 10000 logging.file=/logs/spring-boot-logging.log -spring.profiles.active=devel +spring.profiles.active=staging eu.eudat.logic.proxy.allowed.host=https://eestore.paas2.uninett.no ####################INVITATION MAIL CONFIGURATIONS############## diff --git a/dmp-db-scema/Docker/dmp-db.env b/dmp-db-scema/Docker/dmp-db.env new file mode 100644 index 000000000..d79f408eb --- /dev/null +++ b/dmp-db-scema/Docker/dmp-db.env @@ -0,0 +1,5 @@ +ADMIN_USERNAME=admin +ADMIN_PASSWORD=CHANGEME +POSTGRES_DB=dmptool +POSTGRES_USER=dmptool +POSTGRES_PASSWORD=CHANGEME \ No newline at end of file diff --git a/dmp-db-scema/initdb.sh b/dmp-db-scema/initdb.sh new file mode 100644 index 000000000..5ea5aa8be --- /dev/null +++ b/dmp-db-scema/initdb.sh @@ -0,0 +1,7 @@ +psql -d dmptool -U dmptool -f main/DataManagementPlanDB.sql; +for j in $(ls updates); do + for i in $(ls updates/$j/*.sql); do + echo $i + psql --set=ADMIN_USERNAME="$ADMIN_USERNAME" --set=ADMIN_PASSWORD="$ADMIN_PASSWORD" -d dmptool -U dmptool -f $i; + done +done \ No newline at end of file diff --git a/dmp-db-scema/DataManagementPlanDB.sql b/dmp-db-scema/main/DataManagementPlanDB.sql similarity index 99% rename from dmp-db-scema/DataManagementPlanDB.sql rename to dmp-db-scema/main/DataManagementPlanDB.sql index 7c49dfbb8..9cad64fc8 100644 --- a/dmp-db-scema/DataManagementPlanDB.sql +++ b/dmp-db-scema/main/DataManagementPlanDB.sql @@ -34,7 +34,7 @@ DROP table if exists "UserAuth" cascade; -- CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; --- CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; +CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; SET search_path = public, pg_catalog; @@ -550,8 +550,8 @@ ALTER TABLE "UserDMP" OWNER TO dmptool; REVOKE ALL ON SCHEMA public FROM PUBLIC; -REVOKE ALL ON SCHEMA public FROM postgres; -GRANT ALL ON SCHEMA public TO postgres; +-- REVOKE ALL ON SCHEMA public FROM postgres; +-- GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; diff --git a/dmp-db-scema/updates/01/DMPUser DMPDatasetprofile DMPFinalizedDate .sql b/dmp-db-scema/updates/01/01_DMPUser_DMPDatasetprofile_DMPFinalizedDate.sql similarity index 56% rename from dmp-db-scema/updates/01/DMPUser DMPDatasetprofile DMPFinalizedDate .sql rename to dmp-db-scema/updates/01/01_DMPUser_DMPDatasetprofile_DMPFinalizedDate.sql index 06d569813..8ed97954d 100644 --- a/dmp-db-scema/updates/01/DMPUser DMPDatasetprofile DMPFinalizedDate .sql +++ b/dmp-db-scema/updates/01/01_DMPUser_DMPDatasetprofile_DMPFinalizedDate.sql @@ -1,12 +1,12 @@ INSERT INTO public."UserDMP"( usr, dmp, role) SELECT "Creator", "ID", 0 - FROM public."DMP" + FROM public."DMP"; DELETE FROM public."UserDMP" as us1 using public."UserDMP" as us2 -where us1."id" < us2."id" AND us1."dmp" = us2."dmp" +where us1."id" < us2."id" AND us1."dmp" = us2."dmp"; @@ -31,30 +31,31 @@ WITH ( TABLESPACE pg_default; ALTER TABLE public."DMPDatasetProfile" - OWNER to dmtadm; - +-- OWNER to dmtadm; + OWNER to dmptool; ALTER TABLE public."UserDMP" - OWNER to dmtadm; +-- OWNER to dmtadm; + OWNER to dmptool; -INSERT INTO public."DMPDatasetProfile"( - dmp, datasetprofile) - SELECT "ID", unnest(xpath('/profiles/profile/@profileId', dmpp."AssociatedDmps"::xml)::text[]::UUID[]) - FROM public."DMP" as dmpp +--INSERT INTO public."DMPDatasetProfile"( +-- dmp, datasetprofile) +-- SELECT "ID", unnest(xpath('/profiles/profile/@profileId', dmpp."AssociatedDmps"::xml)::text[]::UUID[]) +-- FROM public."DMP" as dmpp; -Alter table public."DMP" -add "FinalizedDat" timestamp(6) with time zone +ALTER TABLE public."DMP" +ADD "FinalizedDat" timestamp(6) WITH time zone; -update public."DMP" SET "FinalizedDat" = "Modified" -where "Status" = 1 +UPDATE public."DMP" SET "FinalizedDat" = "Modified" +WHERE "Status" = 1; -Alter table public."Dataset" -add "FinalizedDat" timestamp(6) with time zone +ALTER TABLE public."Dataset" +ADD "FinalizedDat" timestamp(6) WITH time zone; -update public."Dataset" SET "FinalizedDat" = "Modified" -where "Status" = 1 +UPDATE public."Dataset" SET "FinalizedDat" = "Modified" +WHERE "Status" = 1; diff --git a/dmp-db-scema/updates/01/DMPisPublic.sql b/dmp-db-scema/updates/01/03_DMPisPublic.sql similarity index 84% rename from dmp-db-scema/updates/01/DMPisPublic.sql rename to dmp-db-scema/updates/01/03_DMPisPublic.sql index aef4dca4d..dab69e4d9 100644 --- a/dmp-db-scema/updates/01/DMPisPublic.sql +++ b/dmp-db-scema/updates/01/03_DMPisPublic.sql @@ -3,5 +3,5 @@ Add "isPublic" boolean NOT NULL Default False; UPDATE public."DMP" SET "isPublic" = True - WHERE "Status" = 1 + WHERE "Status" = 1; \ No newline at end of file diff --git a/dmp-db-scema/updates/01/RenameDatasetColumnFinalizedDat.sql b/dmp-db-scema/updates/01/04_RenameDatasetColumnFinalizedDat.sql similarity index 100% rename from dmp-db-scema/updates/01/RenameDatasetColumnFinalizedDat.sql rename to dmp-db-scema/updates/01/04_RenameDatasetColumnFinalizedDat.sql diff --git a/dmp-db-scema/updates/01/DMPPublishedDat.sql b/dmp-db-scema/updates/01/05_DMPPublishedDat.sql similarity index 53% rename from dmp-db-scema/updates/01/DMPPublishedDat.sql rename to dmp-db-scema/updates/01/05_DMPPublishedDat.sql index 541efc62f..d823b5134 100644 --- a/dmp-db-scema/updates/01/DMPPublishedDat.sql +++ b/dmp-db-scema/updates/01/05_DMPPublishedDat.sql @@ -1,6 +1,6 @@ ALTER TABLE public."DMP" -ADD "PublishedAt" timestamp(6) with time zone +ADD "PublishedAt" timestamp(6) WITH time zone; UPDATE public."DMP" SET "PublishedAt" = "FinalizedDat" -where "isPublic" = True \ No newline at end of file +where "isPublic" = True; \ No newline at end of file diff --git a/dmp-db-scema/updates/01/RenameDMPColumnsFinalizedDatPublishedDat.sql b/dmp-db-scema/updates/01/06_RenameDMPColumnsFinalizedDatPublishedDat.sql similarity index 100% rename from dmp-db-scema/updates/01/RenameDMPColumnsFinalizedDatPublishedDat.sql rename to dmp-db-scema/updates/01/06_RenameDMPColumnsFinalizedDatPublishedDat.sql diff --git a/dmp-db-scema/updates/01/DMPCreateDOI.sql b/dmp-db-scema/updates/01/07_DMPCreateDOI.sql similarity index 53% rename from dmp-db-scema/updates/01/DMPCreateDOI.sql rename to dmp-db-scema/updates/01/07_DMPCreateDOI.sql index 470304b4c..5e97960c0 100644 --- a/dmp-db-scema/updates/01/DMPCreateDOI.sql +++ b/dmp-db-scema/updates/01/07_DMPCreateDOI.sql @@ -1,2 +1,2 @@ ALTER TABLE public."DMP" -ADD COLUMN "DOI" text \ No newline at end of file +ADD COLUMN "DOI" text; \ No newline at end of file diff --git a/dmp-db-scema/updates/01/08_Create_content.sql b/dmp-db-scema/updates/01/08_Create_content.sql new file mode 100644 index 000000000..89c6190b9 --- /dev/null +++ b/dmp-db-scema/updates/01/08_Create_content.sql @@ -0,0 +1,15 @@ +CREATE TABLE public."Content" ( + "Id" uuid NOT NULL, + "Filename" character varying NOT NULL, + "Extension" character varying NOT NULL, + "ParentType" numeric NOT NULL, + "Uri" character varying NOT NULL, + "LocationType" numeric NOT NULL +); + + +ALTER TABLE public."Content" OWNER TO dmptool; + +ALTER TABLE ONLY public."Content" + ADD CONSTRAINT "Content_pkey" PRIMARY KEY ("Id"); + diff --git a/dmp-db-scema/updates/01/Removes DatasetIsPublic.sql b/dmp-db-scema/updates/01/Removes DatasetIsPublic.sql deleted file mode 100644 index 3734d4198..000000000 --- a/dmp-db-scema/updates/01/Removes DatasetIsPublic.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE public."Dataset" -DROP COLUMN "IsPublic" \ No newline at end of file diff --git a/dmp-db-scema/updates/02/CreateLoginConfirmationEmail.sql b/dmp-db-scema/updates/02/01_CreateLoginConfirmationEmail.sql similarity index 90% rename from dmp-db-scema/updates/02/CreateLoginConfirmationEmail.sql rename to dmp-db-scema/updates/02/01_CreateLoginConfirmationEmail.sql index 458b1b572..cf3807730 100644 --- a/dmp-db-scema/updates/02/CreateLoginConfirmationEmail.sql +++ b/dmp-db-scema/updates/02/01_CreateLoginConfirmationEmail.sql @@ -14,4 +14,5 @@ WITH ( TABLESPACE pg_default; ALTER TABLE public."LoginConfirmationEmail" - OWNER to dmtadm; \ No newline at end of file +-- OWNER to dmtadm; + OWNER to dmptool; \ No newline at end of file diff --git a/dmp-db-scema/updates/02/UserInfo email drop null.sql b/dmp-db-scema/updates/02/02_UserInfo_email_drop_null.sql similarity index 100% rename from dmp-db-scema/updates/02/UserInfo email drop null.sql rename to dmp-db-scema/updates/02/02_UserInfo_email_drop_null.sql diff --git a/dmp-db-scema/updates/03/01. DatasetProfile_Description_value_set_empty_text.sql b/dmp-db-scema/updates/03/01_DatasetProfile_Description_value_set_empty_text.sql similarity index 100% rename from dmp-db-scema/updates/03/01. DatasetProfile_Description_value_set_empty_text.sql rename to dmp-db-scema/updates/03/01_DatasetProfile_Description_value_set_empty_text.sql diff --git a/dmp-db-scema/updates/03/02. DatasetProfile_adds_null_constraints_description.sql b/dmp-db-scema/updates/03/02_DatasetProfile_adds_null_constraints_description.sql similarity index 100% rename from dmp-db-scema/updates/03/02. DatasetProfile_adds_null_constraints_description.sql rename to dmp-db-scema/updates/03/02_DatasetProfile_adds_null_constraints_description.sql diff --git a/dmp-db-scema/updates/03/05. Renames-Project-to-Grant.sql b/dmp-db-scema/updates/03/03_Renames-Project-to-Grant.sql similarity index 100% rename from dmp-db-scema/updates/03/05. Renames-Project-to-Grant.sql rename to dmp-db-scema/updates/03/03_Renames-Project-to-Grant.sql diff --git a/dmp-db-scema/updates/03/03. Funder-create.sql b/dmp-db-scema/updates/03/04_Funder-create.sql similarity index 100% rename from dmp-db-scema/updates/03/03. Funder-create.sql rename to dmp-db-scema/updates/03/04_Funder-create.sql diff --git a/dmp-db-scema/updates/03/04. Grant-add-column-Funder.sql b/dmp-db-scema/updates/03/05_Grant-add-column-Funder.sql similarity index 100% rename from dmp-db-scema/updates/03/04. Grant-add-column-Funder.sql rename to dmp-db-scema/updates/03/05_Grant-add-column-Funder.sql diff --git a/dmp-db-scema/updates/03/06_Renames-Grant-fk-Constraint.sql b/dmp-db-scema/updates/03/06_Renames-Grant-fk-Constraint.sql new file mode 100644 index 000000000..9c4dd0602 --- /dev/null +++ b/dmp-db-scema/updates/03/06_Renames-Grant-fk-Constraint.sql @@ -0,0 +1,9 @@ +ALTER TABLE public."Grant" +ADD COLUMN "Content" uuid; + + +ALTER TABLE public."Grant" +ADD CONSTRAINT fk_grant_content FOREIGN KEY ("Content") + REFERENCES public."Content" ("Id") MATCH SIMPLE + ON UPDATE NO ACTION + ON DELETE NO ACTION; \ No newline at end of file diff --git a/dmp-db-scema/updates/03/07. Renames-Grant-fk-creator-Constraint.sql b/dmp-db-scema/updates/03/07_Renames-Grant-fk-creator-Constraint.sql similarity index 100% rename from dmp-db-scema/updates/03/07. Renames-Grant-fk-creator-Constraint.sql rename to dmp-db-scema/updates/03/07_Renames-Grant-fk-creator-Constraint.sql diff --git a/dmp-db-scema/updates/03/08. Renames-Grant-fk-Constraint.sql b/dmp-db-scema/updates/03/08. Renames-Grant-fk-Constraint.sql deleted file mode 100644 index 493d9af69..000000000 --- a/dmp-db-scema/updates/03/08. Renames-Grant-fk-Constraint.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE public."Grant" -RENAME CONSTRAINT "fk_project_content" TO "fk_grant_content"; \ No newline at end of file diff --git a/dmp-db-scema/updates/03/06. Renames-Grant-pKey-Constraint.sql b/dmp-db-scema/updates/03/08_Renames-Grant-pKey-Constraint.sql similarity index 100% rename from dmp-db-scema/updates/03/06. Renames-Grant-pKey-Constraint.sql rename to dmp-db-scema/updates/03/08_Renames-Grant-pKey-Constraint.sql diff --git a/dmp-db-scema/updates/03/09. Rename-Dmps-Project-to_Grant.sql b/dmp-db-scema/updates/03/09_Rename-Dmps-Project-to_Grant.sql similarity index 100% rename from dmp-db-scema/updates/03/09. Rename-Dmps-Project-to_Grant.sql rename to dmp-db-scema/updates/03/09_Rename-Dmps-Project-to_Grant.sql diff --git a/dmp-db-scema/updates/03/10. Project-create.sql b/dmp-db-scema/updates/03/10_Project-create.sql similarity index 100% rename from dmp-db-scema/updates/03/10. Project-create.sql rename to dmp-db-scema/updates/03/10_Project-create.sql diff --git a/dmp-db-scema/updates/03/11. DMP-add-column-project.sql b/dmp-db-scema/updates/03/11_DMP-add-column-project.sql similarity index 100% rename from dmp-db-scema/updates/03/11. DMP-add-column-project.sql rename to dmp-db-scema/updates/03/11_DMP-add-column-project.sql diff --git a/dmp-db-scema/updates/03/12_Remove_xml_types.sql b/dmp-db-scema/updates/03/12_Remove_xml_types.sql new file mode 100644 index 000000000..5bfb2a5f8 --- /dev/null +++ b/dmp-db-scema/updates/03/12_Remove_xml_types.sql @@ -0,0 +1,18 @@ +ALTER TABLE public."Grant" +ALTER COLUMN "Reference" TYPE character varying(255); + +ALTER TABLE public."Grant" +ALTER COLUMN "Definition" TYPE character varying; + +ALTER TABLE public."Registry" +ALTER COLUMN "Reference" TYPE character varying; + +ALTER TABLE public."Service" +ALTER COLUMN "Reference" TYPE character varying; + +ALTER TABLE public."Researcher" +ALTER COLUMN "Reference" TYPE character varying; + +ALTER TABLE public."DataRepository" +ALTER COLUMN "Reference" TYPE character varying; + diff --git a/dmp-db-scema/updates/04/01_Funder_add_column_CreationUser.sql b/dmp-db-scema/updates/04/01_Funder_add_column_CreationUser.sql new file mode 100644 index 000000000..04aa6f4d3 --- /dev/null +++ b/dmp-db-scema/updates/04/01_Funder_add_column_CreationUser.sql @@ -0,0 +1,2 @@ +ALTER TABLE "Funder" +ADD COLUMN "CreationUser" uuid; \ No newline at end of file diff --git a/dmp-db-scema/updates/04/Funder_update_CreationUser_values.sql b/dmp-db-scema/updates/04/02_Funder_update_CreationUser_values.sql similarity index 71% rename from dmp-db-scema/updates/04/Funder_update_CreationUser_values.sql rename to dmp-db-scema/updates/04/02_Funder_update_CreationUser_values.sql index 130130ab9..2d7085f3e 100644 --- a/dmp-db-scema/updates/04/Funder_update_CreationUser_values.sql +++ b/dmp-db-scema/updates/04/02_Funder_update_CreationUser_values.sql @@ -1,4 +1,4 @@ Update "Funder" as funder set "CreationUser" = grant1."CreationUser" from "Grant" as grant1 - where funder."ID" = grant1."Funder" \ No newline at end of file + where funder."ID" = grant1."Funder" ; \ No newline at end of file diff --git a/dmp-db-scema/updates/04/03_Create_External_Datasets.sql b/dmp-db-scema/updates/04/03_Create_External_Datasets.sql new file mode 100644 index 000000000..5c55bcb70 --- /dev/null +++ b/dmp-db-scema/updates/04/03_Create_External_Datasets.sql @@ -0,0 +1,15 @@ +CREATE TABLE public."ExternalDataset" ( + "Id" uuid DEFAULT public.uuid_generate_v4() NOT NULL, + "Label" character varying NOT NULL, + "Abbreviation" character varying, + "Reference" character varying NOT NULL, + "Created" timestamp(4) with time zone NOT NULL, + "Modified" timestamp(4) with time zone NOT NULL +); + + +ALTER TABLE public."ExternalDataset" OWNER TO dmptool; + +ALTER TABLE ONLY public."ExternalDataset" + ADD CONSTRAINT "ExternalDataset_pkey" PRIMARY KEY ("Id"); + diff --git a/dmp-db-scema/updates/04/04_Add_creationUser_on_DataRepository_ExternalDataset_Registry_Service.sql b/dmp-db-scema/updates/04/04_Add_creationUser_on_DataRepository_ExternalDataset_Registry_Service.sql new file mode 100644 index 000000000..fd8dc380d --- /dev/null +++ b/dmp-db-scema/updates/04/04_Add_creationUser_on_DataRepository_ExternalDataset_Registry_Service.sql @@ -0,0 +1,11 @@ +ALTER TABLE "DataRepository" +ADD COLUMN "CreationUser" uuid; + +ALTER TABLE "ExternalDataset" +ADD COLUMN "CreationUser" uuid; + +ALTER TABLE "Registry" +ADD COLUMN "CreationUser" uuid; + +ALTER TABLE "Service" +ADD COLUMN "CreationUser" uuid; \ No newline at end of file diff --git a/dmp-db-scema/updates/04/05_Researcher_add_column_CreationUser.sql b/dmp-db-scema/updates/04/05_Researcher_add_column_CreationUser.sql new file mode 100644 index 000000000..d9627e5bf --- /dev/null +++ b/dmp-db-scema/updates/04/05_Researcher_add_column_CreationUser.sql @@ -0,0 +1,2 @@ +ALTER TABLE "Researcher" +ADD COLUMN "CreationUser" uuid; \ No newline at end of file diff --git a/dmp-db-scema/updates/04/Add_creationUser_on_DataRepository_ExternalDataset_Registry_Service.sql b/dmp-db-scema/updates/04/Add_creationUser_on_DataRepository_ExternalDataset_Registry_Service.sql deleted file mode 100644 index 4cc036bdb..000000000 --- a/dmp-db-scema/updates/04/Add_creationUser_on_DataRepository_ExternalDataset_Registry_Service.sql +++ /dev/null @@ -1,11 +0,0 @@ -ALTER TABLE "DataRepository" -ADD COLUMN "CreationUser" uuid - -ALTER TABLE "ExternalDataset" -ADD COLUMN "CreationUser" uuid - -ALTER TABLE "Registry" -ADD COLUMN "CreationUser" uuid - -ALTER TABLE "Service" -ADD COLUMN "CreationUser" uuid \ No newline at end of file diff --git a/dmp-db-scema/updates/04/Funder_add_column_CreationUser.sql b/dmp-db-scema/updates/04/Funder_add_column_CreationUser.sql deleted file mode 100644 index 7c84eb69f..000000000 --- a/dmp-db-scema/updates/04/Funder_add_column_CreationUser.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE "Funder" -ADD COLUMN "CreationUser" uuid \ No newline at end of file diff --git a/dmp-db-scema/updates/04/Researcher_add_column_CreationUser.sql b/dmp-db-scema/updates/04/Researcher_add_column_CreationUser.sql deleted file mode 100644 index 55b7a4542..000000000 --- a/dmp-db-scema/updates/04/Researcher_add_column_CreationUser.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE "Researcher" -ADD COLUMN "CreationUser" uuid \ No newline at end of file diff --git a/dmp-db-scema/updates/05/External_References_Reference_Prefix_Update.sql b/dmp-db-scema/updates/05/01_External_References_Reference_Prefix_Update.sql similarity index 100% rename from dmp-db-scema/updates/05/External_References_Reference_Prefix_Update.sql rename to dmp-db-scema/updates/05/01_External_References_Reference_Prefix_Update.sql diff --git a/dmp-db-scema/updates/05/Grant_Funder_Project_Reference_Prefix_Update.sql b/dmp-db-scema/updates/05/02_Grant_Funder_Project_Reference_Prefix_Update.sql similarity index 100% rename from dmp-db-scema/updates/05/Grant_Funder_Project_Reference_Prefix_Update.sql rename to dmp-db-scema/updates/05/02_Grant_Funder_Project_Reference_Prefix_Update.sql diff --git a/dmp-db-scema/updates/06/04_Update_Researcher_Reference_First_Character_To_Lower_Where_Capital.sql b/dmp-db-scema/updates/06/04_Update_Researcher_Reference_First_Character_To_Lower_Where_Capital.sql deleted file mode 100644 index 8c3bcc984..000000000 --- a/dmp-db-scema/updates/06/04_Update_Researcher_Reference_First_Character_To_Lower_Where_Capital.sql +++ /dev/null @@ -1,6 +0,0 @@ -UPDATE "Researcher" -SET "Reference" = CONCAT(LOWER(LEFT("Reference", 1)), SUBSTRING("Reference", 2)) -WHERE "ID" in ( - SELECT "ID" FROM "Researcher" - WHERE ASCII(LEFT("Reference", 1)) BETWEEN ASCII('A') AND ASCII('Z') -) \ No newline at end of file diff --git a/dmp-db-scema/updates/08/02_Add_missing_columns.sql b/dmp-db-scema/updates/08/02_Add_missing_columns.sql new file mode 100644 index 000000000..4036dcdc7 --- /dev/null +++ b/dmp-db-scema/updates/08/02_Add_missing_columns.sql @@ -0,0 +1,17 @@ +ALTER TABLE public."DMP" +ADD COLUMN "DmpProperties" text; + +ALTER TABLE public."DMP" +ADD COLUMN "GroupId" uuid; + +ALTER TABLE public."DMP" +ADD COLUMN "Properties" text; + +ALTER TABLE public."DatasetProfile" +ADD COLUMN "GroupId" uuid; + +ALTER TABLE public."DatasetProfile" +ADD COLUMN "Version" integer; + +ALTER TABLE public."Grant" +ADD COLUMN "Type" numeric NOT NULL; \ No newline at end of file diff --git a/dmp-db-scema/updates/08/03_Create_Credentials.sql b/dmp-db-scema/updates/08/03_Create_Credentials.sql new file mode 100644 index 000000000..0ffbf0f46 --- /dev/null +++ b/dmp-db-scema/updates/08/03_Create_Credentials.sql @@ -0,0 +1,25 @@ +CREATE TABLE public."Credential" ( + "Id" uuid NOT NULL, + "Status" numeric NOT NULL, + "Provider" numeric NOT NULL, + "Public" character varying NOT NULL, + "Secret" character varying NOT NULL, + "CreationTime" timestamp(4) with time zone NOT NULL, + "LastUpdateTime" timestamp(4) with time zone NOT NULL, + "UserId" uuid NOT NULL, + "ExternalId" character varying NOT NULL +); + + +ALTER TABLE public."Credential" OWNER TO dmptool; + +ALTER TABLE ONLY public."Credential" + ADD CONSTRAINT "Credential_pkey" PRIMARY KEY ("Id"); + +ALTER TABLE ONLY public."Credential" + ADD CONSTRAINT fkey_credential_user FOREIGN KEY ("UserId") REFERENCES public."UserInfo"(id); + +INSERT INTO public."UserInfo"(email, authorization_level, usertype, name, created, additionalinfo) VALUES ('fake@email.org', 1, 1, :'ADMIN_USERNAME', now(), '{}'); + +INSERT INTO public."Credential" VALUES (uuid_generate_v4(), 0, 5, :'ADMIN_USERNAME', :'ADMIN_PASSWORD', now(), now(), (SELECT public."UserInfo"."id" FROM public."UserInfo" WHERE name = 'admin'), 'dmp'); + diff --git a/dmp-db-scema/updates/08/04_Create_UserToken.sql b/dmp-db-scema/updates/08/04_Create_UserToken.sql new file mode 100644 index 000000000..85ff8103a --- /dev/null +++ b/dmp-db-scema/updates/08/04_Create_UserToken.sql @@ -0,0 +1,16 @@ +CREATE TABLE public."UserToken" ( + "Token" uuid NOT NULL, + "UserId" uuid NOT NULL, + "IssuedAt" timestamp(4) with time zone NOT NULL, + "ExpiresAt" timestamp(4) with time zone NOT NULL +); + + +ALTER TABLE public."UserToken" OWNER TO dmptool; + +ALTER TABLE ONLY public."UserToken" + ADD CONSTRAINT "UserToken_pkey" PRIMARY KEY ("Token"); + +ALTER TABLE ONLY public."UserToken" + ADD CONSTRAINT fkey_usetoken_user FOREIGN KEY ("UserId") REFERENCES public."UserInfo"(id); + diff --git a/dmp-db-scema/updates/08/05_Create_UserRole.sql b/dmp-db-scema/updates/08/05_Create_UserRole.sql new file mode 100644 index 000000000..0db9f39d0 --- /dev/null +++ b/dmp-db-scema/updates/08/05_Create_UserRole.sql @@ -0,0 +1,18 @@ +CREATE TABLE public."UserRole" ( + "Id" uuid DEFAULT public.uuid_generate_v4() NOT NULL, + "Role" numeric DEFAULT 0 NOT NULL, + "UserId" uuid NOT NULL +); + + +ALTER TABLE public."UserRole" OWNER TO dmptool; + +ALTER TABLE ONLY public."UserRole" + ADD CONSTRAINT "UserRole_pkey" PRIMARY KEY ("Id"); + +ALTER TABLE ONLY public."UserRole" + ADD CONSTRAINT "UserRole_userId_fkey" FOREIGN KEY ("UserId") REFERENCES public."UserInfo"(id); + + +INSERT INTO public."UserRole"("Role", "UserId") VALUES (2, (SELECT public."UserInfo"."id" FROM public."UserInfo" WHERE name = 'admin')); + diff --git a/dmp-db-scema/updates/08/06_Remove_UserAuth.sql b/dmp-db-scema/updates/08/06_Remove_UserAuth.sql new file mode 100644 index 000000000..5ed59655c --- /dev/null +++ b/dmp-db-scema/updates/08/06_Remove_UserAuth.sql @@ -0,0 +1 @@ +DROP TABLE IF EXISTS "UserAuth" CASCADE; \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index ac90b8444..f5a46f45d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,8 +1,25 @@ -version: '2.2' +version: "2.4" services: + dmp-db: + image: postgres + container_name: opendmp-db + restart: unless-stopped + ports: + - "5001:5432" + expose: + - "5432" + volumes: + - dmpdata:/var/lib/postgresql/data + - ./dmp-db-scema:/docker-entrypoint-initdb.d/ + - ./dmp-db-scema/main:/main + - ./dmp-db-scema/updates:/updates + env_file: ./dmp-db-scema/Docker/dmp-db.env + networks: + - opendmp-backend-network + dmp-backend: - build: + build: context: ./dmp-backend container_name: opendmp-backend env_file: ./dmp-backend/Docker/dmp-backend.env @@ -38,4 +55,7 @@ services: networks: opendmp-frontend-network: - opendmp-backend-network: \ No newline at end of file + opendmp-backend-network: +volumes: + dmpdata: + external: true