Browse Source

Added postgres on docker compose

Remove_explore
George Kalampokis 2 years ago
parent
commit
75fc400349
  1. 2
      dmp-backend/web/src/main/resources/config/application.properties
  2. 5
      dmp-db-scema/Docker/dmp-db.env
  3. 7
      dmp-db-scema/initdb.sh
  4. 6
      dmp-db-scema/main/DataManagementPlanDB.sql
  5. 35
      dmp-db-scema/updates/01/01_DMPUser_DMPDatasetprofile_DMPFinalizedDate.sql
  6. 2
      dmp-db-scema/updates/01/03_DMPisPublic.sql
  7. 0
      dmp-db-scema/updates/01/04_RenameDatasetColumnFinalizedDat.sql
  8. 4
      dmp-db-scema/updates/01/05_DMPPublishedDat.sql
  9. 0
      dmp-db-scema/updates/01/06_RenameDMPColumnsFinalizedDatPublishedDat.sql
  10. 2
      dmp-db-scema/updates/01/07_DMPCreateDOI.sql
  11. 15
      dmp-db-scema/updates/01/08_Create_content.sql
  12. 2
      dmp-db-scema/updates/01/Removes DatasetIsPublic.sql
  13. 3
      dmp-db-scema/updates/02/01_CreateLoginConfirmationEmail.sql
  14. 0
      dmp-db-scema/updates/02/02_UserInfo_email_drop_null.sql
  15. 0
      dmp-db-scema/updates/03/01_DatasetProfile_Description_value_set_empty_text.sql
  16. 0
      dmp-db-scema/updates/03/02_DatasetProfile_adds_null_constraints_description.sql
  17. 0
      dmp-db-scema/updates/03/03_Renames-Project-to-Grant.sql
  18. 0
      dmp-db-scema/updates/03/04_Funder-create.sql
  19. 0
      dmp-db-scema/updates/03/05_Grant-add-column-Funder.sql
  20. 9
      dmp-db-scema/updates/03/06_Renames-Grant-fk-Constraint.sql
  21. 0
      dmp-db-scema/updates/03/07_Renames-Grant-fk-creator-Constraint.sql
  22. 2
      dmp-db-scema/updates/03/08. Renames-Grant-fk-Constraint.sql
  23. 0
      dmp-db-scema/updates/03/08_Renames-Grant-pKey-Constraint.sql
  24. 0
      dmp-db-scema/updates/03/09_Rename-Dmps-Project-to_Grant.sql
  25. 0
      dmp-db-scema/updates/03/10_Project-create.sql
  26. 0
      dmp-db-scema/updates/03/11_DMP-add-column-project.sql
  27. 18
      dmp-db-scema/updates/03/12_Remove_xml_types.sql
  28. 2
      dmp-db-scema/updates/04/01_Funder_add_column_CreationUser.sql
  29. 2
      dmp-db-scema/updates/04/02_Funder_update_CreationUser_values.sql
  30. 15
      dmp-db-scema/updates/04/03_Create_External_Datasets.sql
  31. 11
      dmp-db-scema/updates/04/04_Add_creationUser_on_DataRepository_ExternalDataset_Registry_Service.sql
  32. 2
      dmp-db-scema/updates/04/05_Researcher_add_column_CreationUser.sql
  33. 11
      dmp-db-scema/updates/04/Add_creationUser_on_DataRepository_ExternalDataset_Registry_Service.sql
  34. 2
      dmp-db-scema/updates/04/Funder_add_column_CreationUser.sql
  35. 2
      dmp-db-scema/updates/04/Researcher_add_column_CreationUser.sql
  36. 0
      dmp-db-scema/updates/05/01_External_References_Reference_Prefix_Update.sql
  37. 0
      dmp-db-scema/updates/05/02_Grant_Funder_Project_Reference_Prefix_Update.sql
  38. 6
      dmp-db-scema/updates/06/04_Update_Researcher_Reference_First_Character_To_Lower_Where_Capital.sql
  39. 17
      dmp-db-scema/updates/08/02_Add_missing_columns.sql
  40. 25
      dmp-db-scema/updates/08/03_Create_Credentials.sql
  41. 16
      dmp-db-scema/updates/08/04_Create_UserToken.sql
  42. 18
      dmp-db-scema/updates/08/05_Create_UserRole.sql
  43. 1
      dmp-db-scema/updates/08/06_Remove_UserAuth.sql
  44. 26
      docker-compose.yml

2
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##############

5
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

7
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

6
dmp-db-scema/DataManagementPlanDB.sql → 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;

35
dmp-db-scema/updates/01/DMPUser DMPDatasetprofile DMPFinalizedDate .sql → 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;

2
dmp-db-scema/updates/01/DMPisPublic.sql → 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;

0
dmp-db-scema/updates/01/RenameDatasetColumnFinalizedDat.sql → dmp-db-scema/updates/01/04_RenameDatasetColumnFinalizedDat.sql

4
dmp-db-scema/updates/01/DMPPublishedDat.sql → 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
where "isPublic" = True;

0
dmp-db-scema/updates/01/RenameDMPColumnsFinalizedDatPublishedDat.sql → dmp-db-scema/updates/01/06_RenameDMPColumnsFinalizedDatPublishedDat.sql

2
dmp-db-scema/updates/01/DMPCreateDOI.sql → dmp-db-scema/updates/01/07_DMPCreateDOI.sql

@ -1,2 +1,2 @@
ALTER TABLE public."DMP"
ADD COLUMN "DOI" text
ADD COLUMN "DOI" text;

15
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");

2
dmp-db-scema/updates/01/Removes DatasetIsPublic.sql

@ -1,2 +0,0 @@
ALTER TABLE public."Dataset"
DROP COLUMN "IsPublic"

3
dmp-db-scema/updates/02/CreateLoginConfirmationEmail.sql → dmp-db-scema/updates/02/01_CreateLoginConfirmationEmail.sql

@ -14,4 +14,5 @@ WITH (
TABLESPACE pg_default;
ALTER TABLE public."LoginConfirmationEmail"
OWNER to dmtadm;
-- OWNER to dmtadm;
OWNER to dmptool;

0
dmp-db-scema/updates/02/UserInfo email drop null.sql → dmp-db-scema/updates/02/02_UserInfo_email_drop_null.sql

0
dmp-db-scema/updates/03/01. DatasetProfile_Description_value_set_empty_text.sql → dmp-db-scema/updates/03/01_DatasetProfile_Description_value_set_empty_text.sql

0
dmp-db-scema/updates/03/02. DatasetProfile_adds_null_constraints_description.sql → dmp-db-scema/updates/03/02_DatasetProfile_adds_null_constraints_description.sql

0
dmp-db-scema/updates/03/05. Renames-Project-to-Grant.sql → dmp-db-scema/updates/03/03_Renames-Project-to-Grant.sql

0
dmp-db-scema/updates/03/03. Funder-create.sql → dmp-db-scema/updates/03/04_Funder-create.sql

0
dmp-db-scema/updates/03/04. Grant-add-column-Funder.sql → dmp-db-scema/updates/03/05_Grant-add-column-Funder.sql

9
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;

0
dmp-db-scema/updates/03/07. Renames-Grant-fk-creator-Constraint.sql → dmp-db-scema/updates/03/07_Renames-Grant-fk-creator-Constraint.sql

2
dmp-db-scema/updates/03/08. Renames-Grant-fk-Constraint.sql

@ -1,2 +0,0 @@
ALTER TABLE public."Grant"
RENAME CONSTRAINT "fk_project_content" TO "fk_grant_content";

0
dmp-db-scema/updates/03/06. Renames-Grant-pKey-Constraint.sql → dmp-db-scema/updates/03/08_Renames-Grant-pKey-Constraint.sql

0
dmp-db-scema/updates/03/09. Rename-Dmps-Project-to_Grant.sql → dmp-db-scema/updates/03/09_Rename-Dmps-Project-to_Grant.sql

0
dmp-db-scema/updates/03/10. Project-create.sql → dmp-db-scema/updates/03/10_Project-create.sql

0
dmp-db-scema/updates/03/11. DMP-add-column-project.sql → dmp-db-scema/updates/03/11_DMP-add-column-project.sql

18
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;

2
dmp-db-scema/updates/04/01_Funder_add_column_CreationUser.sql

@ -0,0 +1,2 @@
ALTER TABLE "Funder"
ADD COLUMN "CreationUser" uuid;

2
dmp-db-scema/updates/04/Funder_update_CreationUser_values.sql → 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"
where funder."ID" = grant1."Funder" ;

15
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");

11
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;

2
dmp-db-scema/updates/04/05_Researcher_add_column_CreationUser.sql

@ -0,0 +1,2 @@
ALTER TABLE "Researcher"
ADD COLUMN "CreationUser" uuid;

11
dmp-db-scema/updates/04/Add_creationUser_on_DataRepository_ExternalDataset_Registry_Service.sql

@ -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

2
dmp-db-scema/updates/04/Funder_add_column_CreationUser.sql

@ -1,2 +0,0 @@
ALTER TABLE "Funder"
ADD COLUMN "CreationUser" uuid

2
dmp-db-scema/updates/04/Researcher_add_column_CreationUser.sql

@ -1,2 +0,0 @@
ALTER TABLE "Researcher"
ADD COLUMN "CreationUser" uuid

0
dmp-db-scema/updates/05/External_References_Reference_Prefix_Update.sql → dmp-db-scema/updates/05/01_External_References_Reference_Prefix_Update.sql

0
dmp-db-scema/updates/05/Grant_Funder_Project_Reference_Prefix_Update.sql → dmp-db-scema/updates/05/02_Grant_Funder_Project_Reference_Prefix_Update.sql

6
dmp-db-scema/updates/06/04_Update_Researcher_Reference_First_Character_To_Lower_Where_Capital.sql

@ -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')
)

17
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;

25
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');

16
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);

18
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'));

1
dmp-db-scema/updates/08/06_Remove_UserAuth.sql

@ -0,0 +1 @@
DROP TABLE IF EXISTS "UserAuth" CASCADE;

26
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:
opendmp-backend-network:
volumes:
dmpdata:
external: true

Loading…
Cancel
Save