diff --git a/dmp-db-scema/main/data-dump.sql b/dmp-db-scema/main/data-dump.sql index 297407a37..cdb27f077 100644 --- a/dmp-db-scema/main/data-dump.sql +++ b/dmp-db-scema/main/data-dump.sql @@ -14,4 +14,4 @@ INSERT INTO public."DoiFunder"(name, doi) VALUES ('National Science Foundation', INSERT INTO public."DoiFunder"(name, doi) VALUES ('Nederlandse Organisatie voor Wetenschappelijk Onderzoek', '10.13039/501100003246'); INSERT INTO public."DoiFunder"(name, doi) VALUES ('Wellcome Trust', '10.13039/100004440'); -INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.00.002', '2020-05-06 18:11:00.000000+03', now(), 'Add Doi Funder'); \ No newline at end of file +INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.00.003', '2020-05-06 18:11:00.000000+03', now(), 'Add Doi Funder'); \ No newline at end of file diff --git a/dmp-db-scema/updates/09/01_create_user_association.sql b/dmp-db-scema/updates/00.00.002_create_user_association.sql similarity index 100% rename from dmp-db-scema/updates/09/01_create_user_association.sql rename to dmp-db-scema/updates/00.00.002_create_user_association.sql diff --git a/dmp-db-scema/updates/09/02_doifunder.sql b/dmp-db-scema/updates/00.00.003_doifunder.sql similarity index 91% rename from dmp-db-scema/updates/09/02_doifunder.sql rename to dmp-db-scema/updates/00.00.003_doifunder.sql index 53894a997..7d01346ad 100644 --- a/dmp-db-scema/updates/09/02_doifunder.sql +++ b/dmp-db-scema/updates/00.00.003_doifunder.sql @@ -20,5 +20,7 @@ INSERT INTO public."DoiFunder"(name, doi) VALUES ('National Science Foundation', INSERT INTO public."DoiFunder"(name, doi) VALUES ('Nederlandse Organisatie voor Wetenschappelijk Onderzoek', '10.13039/501100003246'); INSERT INTO public."DoiFunder"(name, doi) VALUES ('Wellcome Trust', '10.13039/100004440'); +INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.00.003', '2020-05-06 18:11:00.000000+03', now(), 'Add Doi Funder'); + diff --git a/dmp-db-scema/updates/01/01_DMPUser_DMPDatasetprofile_DMPFinalizedDate.sql b/dmp-db-scema/updates/01/01_DMPUser_DMPDatasetprofile_DMPFinalizedDate.sql deleted file mode 100644 index cbb256489..000000000 --- a/dmp-db-scema/updates/01/01_DMPUser_DMPDatasetprofile_DMPFinalizedDate.sql +++ /dev/null @@ -1,61 +0,0 @@ -INSERT INTO public."UserDMP"( - usr, dmp, role) - SELECT "Creator", "ID", 0 - FROM public."DMP"; - -DELETE -FROM public."UserDMP" as us1 -using public."UserDMP" as us2 -where us1."id" < us2."id" AND us1."dmp" = us2."dmp"; - - - -CREATE TABLE public."DMPDatasetProfile" -( - "ID" uuid NOT NULL DEFAULT uuid_generate_v4(), - dmp uuid NOT NULL, - datasetprofile uuid NOT NULL, - CONSTRAINT "DMPDatasetProfile_pkey" PRIMARY KEY ("ID"), - CONSTRAINT "DMPDatasetProfile_datasetprofile_fkey" FOREIGN KEY (datasetprofile) - REFERENCES public."DatasetProfile" ("ID") MATCH SIMPLE - ON UPDATE NO ACTION - ON DELETE NO ACTION, - CONSTRAINT "DMPDatasetProfile_dmp_fkey" FOREIGN KEY (dmp) - REFERENCES public."DMP" ("ID") MATCH SIMPLE - ON UPDATE NO ACTION - ON DELETE NO ACTION -) -WITH ( - OIDS = FALSE -) -TABLESPACE pg_default; - -ALTER TABLE public."DMPDatasetProfile" --- OWNER to dmtadm; - OWNER to :POSTGRES_USER; - - -ALTER TABLE public."UserDMP" --- OWNER to dmtadm; - OWNER to :POSTGRES_USER; - - ---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; - -UPDATE public."DMP" SET "FinalizedDat" = "Modified" -WHERE "Status" = 1; - - -ALTER TABLE public."Dataset" -ADD "FinalizedDat" timestamp(6) WITH time zone; - -UPDATE public."Dataset" SET "FinalizedDat" = "Modified" -WHERE "Status" = 1; diff --git a/dmp-db-scema/updates/01/03_DMPisPublic.sql b/dmp-db-scema/updates/01/03_DMPisPublic.sql deleted file mode 100644 index dab69e4d9..000000000 --- a/dmp-db-scema/updates/01/03_DMPisPublic.sql +++ /dev/null @@ -1,7 +0,0 @@ -alter table public."DMP" -Add "isPublic" boolean NOT NULL Default False; - -UPDATE public."DMP" - SET "isPublic" = True - WHERE "Status" = 1; - \ No newline at end of file diff --git a/dmp-db-scema/updates/01/04_RenameDatasetColumnFinalizedDat.sql b/dmp-db-scema/updates/01/04_RenameDatasetColumnFinalizedDat.sql deleted file mode 100644 index e983e21dd..000000000 --- a/dmp-db-scema/updates/01/04_RenameDatasetColumnFinalizedDat.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE public."Dataset" - RENAME COLUMN "FinalizedDat" TO "FinalizedAt"; \ No newline at end of file diff --git a/dmp-db-scema/updates/01/05_DMPPublishedDat.sql b/dmp-db-scema/updates/01/05_DMPPublishedDat.sql deleted file mode 100644 index d823b5134..000000000 --- a/dmp-db-scema/updates/01/05_DMPPublishedDat.sql +++ /dev/null @@ -1,6 +0,0 @@ -ALTER TABLE public."DMP" -ADD "PublishedAt" timestamp(6) WITH time zone; - -UPDATE public."DMP" -SET "PublishedAt" = "FinalizedDat" -where "isPublic" = True; \ No newline at end of file diff --git a/dmp-db-scema/updates/01/06_RenameDMPColumnsFinalizedDatPublishedDat.sql b/dmp-db-scema/updates/01/06_RenameDMPColumnsFinalizedDatPublishedDat.sql deleted file mode 100644 index 557f625b7..000000000 --- a/dmp-db-scema/updates/01/06_RenameDMPColumnsFinalizedDatPublishedDat.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE public."DMP" - RENAME COLUMN "FinalizedDat" TO "FinalizedAt"; \ No newline at end of file diff --git a/dmp-db-scema/updates/01/07_DMPCreateDOI.sql b/dmp-db-scema/updates/01/07_DMPCreateDOI.sql deleted file mode 100644 index 5e97960c0..000000000 --- a/dmp-db-scema/updates/01/07_DMPCreateDOI.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE public."DMP" -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 deleted file mode 100644 index f88ef3351..000000000 --- a/dmp-db-scema/updates/01/08_Create_content.sql +++ /dev/null @@ -1,15 +0,0 @@ -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 :POSTGRES_USER; - -ALTER TABLE ONLY public."Content" - ADD CONSTRAINT "Content_pkey" PRIMARY KEY ("Id"); - diff --git a/dmp-db-scema/updates/02/01_CreateLoginConfirmationEmail.sql b/dmp-db-scema/updates/02/01_CreateLoginConfirmationEmail.sql deleted file mode 100644 index a21039942..000000000 --- a/dmp-db-scema/updates/02/01_CreateLoginConfirmationEmail.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE TABLE public."LoginConfirmationEmail" -( - "ID" uuid NOT NULL, - email character varying COLLATE pg_catalog."default" NOT NULL, - "isConfirmed" boolean NOT NULL, - token uuid NOT NULL, - userId uuid NOT NULL, - "expiresAt" timestamp(4) with time zone NOT NULL, - CONSTRAINT "LoginConfirmationEmail_pkey" PRIMARY KEY ("ID") -) -WITH ( - OIDS = FALSE -) -TABLESPACE pg_default; - -ALTER TABLE public."LoginConfirmationEmail" --- OWNER to dmtadm; - OWNER to :POSTGRES_USER; \ No newline at end of file diff --git a/dmp-db-scema/updates/02/02_UserInfo_email_drop_null.sql b/dmp-db-scema/updates/02/02_UserInfo_email_drop_null.sql deleted file mode 100644 index 4516a079d..000000000 --- a/dmp-db-scema/updates/02/02_UserInfo_email_drop_null.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE public."UserInfo" -ALTER COLUMN "email" -DROP NOT NULL \ No newline at end of file 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 deleted file mode 100644 index ebace6011..000000000 --- a/dmp-db-scema/updates/03/01_DatasetProfile_Description_value_set_empty_text.sql +++ /dev/null @@ -1,2 +0,0 @@ -UPDATE public."DatasetProfile" -SET "Description" = '' \ No newline at end of file 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 deleted file mode 100644 index 569b443a9..000000000 --- a/dmp-db-scema/updates/03/02_DatasetProfile_adds_null_constraints_description.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE public."DatasetProfile" -ALTER COLUMN "Description" -SET NOT NULL \ No newline at end of file diff --git a/dmp-db-scema/updates/03/03_Renames-Project-to-Grant.sql b/dmp-db-scema/updates/03/03_Renames-Project-to-Grant.sql deleted file mode 100644 index dd2ca5c2b..000000000 --- a/dmp-db-scema/updates/03/03_Renames-Project-to-Grant.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE "Project" -RENAME TO "Grant"; \ No newline at end of file diff --git a/dmp-db-scema/updates/03/04_Funder-create.sql b/dmp-db-scema/updates/03/04_Funder-create.sql deleted file mode 100644 index b6766b7f7..000000000 --- a/dmp-db-scema/updates/03/04_Funder-create.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE public."Funder" -( - "ID" uuid NOT NULL DEFAULT uuid_generate_v4(), - "Label" character varying(250) COLLATE pg_catalog."default" NOT NULL, - "Reference" character varying COLLATE pg_catalog."default", - "Definition" character varying COLLATE pg_catalog."default", - "Status" smallint NOT NULL DEFAULT 0, - "Created" timestamp(4) with time zone NOT NULL DEFAULT now(), - "Modified" timestamp(4) with time zone NOT NULL DEFAULT now(), - "Type" numeric NOT NULL DEFAULT 0, - CONSTRAINT "Funder_pkey" PRIMARY KEY ("ID") -) \ No newline at end of file diff --git a/dmp-db-scema/updates/03/05_Grant-add-column-Funder.sql b/dmp-db-scema/updates/03/05_Grant-add-column-Funder.sql deleted file mode 100644 index d3a4d93d2..000000000 --- a/dmp-db-scema/updates/03/05_Grant-add-column-Funder.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE "Grant" -ADD COLUMN "Funder" uuid \ No newline at end of file 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 deleted file mode 100644 index 9c4dd0602..000000000 --- a/dmp-db-scema/updates/03/06_Renames-Grant-fk-Constraint.sql +++ /dev/null @@ -1,9 +0,0 @@ -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 deleted file mode 100644 index 6e0a8ff3a..000000000 --- a/dmp-db-scema/updates/03/07_Renames-Grant-fk-creator-Constraint.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE public."Grant" -RENAME CONSTRAINT "fk_project_creator" TO "fk_grant_creator"; \ No newline at end of file diff --git a/dmp-db-scema/updates/03/08_Renames-Grant-pKey-Constraint.sql b/dmp-db-scema/updates/03/08_Renames-Grant-pKey-Constraint.sql deleted file mode 100644 index c0ffc4b23..000000000 --- a/dmp-db-scema/updates/03/08_Renames-Grant-pKey-Constraint.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE public."Grant" -RENAME CONSTRAINT "Project_pkey" TO "Grant_pkey"; \ No newline at end of file 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 deleted file mode 100644 index 23d5b198f..000000000 --- a/dmp-db-scema/updates/03/09_Rename-Dmps-Project-to_Grant.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE public."DMP" -RENAME COLUMN "Project" to "Grant" \ No newline at end of file diff --git a/dmp-db-scema/updates/03/10_Project-create.sql b/dmp-db-scema/updates/03/10_Project-create.sql deleted file mode 100644 index 7f1f6b62e..000000000 --- a/dmp-db-scema/updates/03/10_Project-create.sql +++ /dev/null @@ -1,27 +0,0 @@ -CREATE TABLE public."Project" -( - "ID" uuid NOT NULL DEFAULT uuid_generate_v4(), - "Label" character varying(250) COLLATE pg_catalog."default" NOT NULL, - "Abbreviation" character varying(50) COLLATE pg_catalog."default", - "Reference" character varying COLLATE pg_catalog."default", - "Uri" character varying(250) COLLATE pg_catalog."default", - "Definition" character varying COLLATE pg_catalog."default", - "Status" smallint NOT NULL DEFAULT 0, - "Created" timestamp(4) with time zone NOT NULL DEFAULT now(), - "Modified" timestamp(4) with time zone NOT NULL DEFAULT now(), - "StartDate" timestamp(4) with time zone, - "EndDate" timestamp(4) with time zone, - "Description" text COLLATE pg_catalog."default", - "CreationUser" uuid, - "Type" numeric NOT NULL DEFAULT 0, - "Content" uuid, - CONSTRAINT "Project_pkey" PRIMARY KEY ("ID"), - CONSTRAINT fk_project_content FOREIGN KEY ("Content") - REFERENCES public."Content" ("Id") MATCH SIMPLE - ON UPDATE NO ACTION - ON DELETE NO ACTION, - CONSTRAINT fk_project_creator FOREIGN KEY ("CreationUser") - REFERENCES public."UserInfo" (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/11_DMP-add-column-project.sql b/dmp-db-scema/updates/03/11_DMP-add-column-project.sql deleted file mode 100644 index e72d6afe7..000000000 --- a/dmp-db-scema/updates/03/11_DMP-add-column-project.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE public."DMP" -ADD COLUMN "Project" uuid \ No newline at end of file diff --git a/dmp-db-scema/updates/03/12_Remove_xml_types.sql b/dmp-db-scema/updates/03/12_Remove_xml_types.sql deleted file mode 100644 index 5bfb2a5f8..000000000 --- a/dmp-db-scema/updates/03/12_Remove_xml_types.sql +++ /dev/null @@ -1,18 +0,0 @@ -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 deleted file mode 100644 index 04aa6f4d3..000000000 --- a/dmp-db-scema/updates/04/01_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/02_Funder_update_CreationUser_values.sql b/dmp-db-scema/updates/04/02_Funder_update_CreationUser_values.sql deleted file mode 100644 index 2d7085f3e..000000000 --- a/dmp-db-scema/updates/04/02_Funder_update_CreationUser_values.sql +++ /dev/null @@ -1,4 +0,0 @@ -Update "Funder" as funder - set "CreationUser" = grant1."CreationUser" - from "Grant" as grant1 - 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 deleted file mode 100644 index 015df00e0..000000000 --- a/dmp-db-scema/updates/04/03_Create_External_Datasets.sql +++ /dev/null @@ -1,15 +0,0 @@ -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 :POSTGRES_USER; - -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 deleted file mode 100644 index fd8dc380d..000000000 --- a/dmp-db-scema/updates/04/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/05_Researcher_add_column_CreationUser.sql b/dmp-db-scema/updates/04/05_Researcher_add_column_CreationUser.sql deleted file mode 100644 index d9627e5bf..000000000 --- a/dmp-db-scema/updates/04/05_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/01_External_References_Reference_Prefix_Update.sql b/dmp-db-scema/updates/05/01_External_References_Reference_Prefix_Update.sql deleted file mode 100644 index 615ebb4c9..000000000 --- a/dmp-db-scema/updates/05/01_External_References_Reference_Prefix_Update.sql +++ /dev/null @@ -1,31 +0,0 @@ --- Registry Update Script -UPDATE public."Registry" -SET "Reference" = REPLACE("Reference", 'dmpdata/', 'dmp:') -WHERE "Reference" LIKE 'dmpdata/%'; - --- Service Update Script -UPDATE public."Service" -SET "Reference" = REPLACE("Reference", 'dmpdata/', 'dmp:') -WHERE "Reference" LIKE 'dmpdata/%'; -UPDATE public."Service" -SET "Reference" = REPLACE("Reference", 'innerdata/', 'dmp:') -WHERE "Reference" LIKE 'innerdata/%'; - --- DataRepository -UPDATE public."DataRepository" -SET "Reference" = REPLACE("Reference", 'dmpdata/', 'dmp:') -where "Reference" like 'dmpdata/%'; -UPDATE public."DataRepository" -SET "Reference" = CONCAT('re3data:', "Reference") -where "Reference" LIKE '%:re3data%'; -UPDATE public."DataRepository" -SET "Reference" = CONCAT('dmp:', "Reference") -where "Reference" LIKE '%:internal%'; -UPDATE public."DataRepository" -SET "Reference" = CONCAT('eestore:', "Reference") -where "Reference" LIKE '%:eestore%'; - --- ExternalDataset -UPDATE public."ExternalDataset" -SET "Reference" = REPLACE("Reference", 'dmpdata/', 'dmp:') -WHERE "Reference" LIKE 'dmpdata/%'; \ No newline at end of file diff --git a/dmp-db-scema/updates/05/02_Grant_Funder_Project_Reference_Prefix_Update.sql b/dmp-db-scema/updates/05/02_Grant_Funder_Project_Reference_Prefix_Update.sql deleted file mode 100644 index bb1e529fe..000000000 --- a/dmp-db-scema/updates/05/02_Grant_Funder_Project_Reference_Prefix_Update.sql +++ /dev/null @@ -1,26 +0,0 @@ --- Grant -UPDATE public."Grant" -SET "Reference" = CONCAT('cristin:', "Reference") -WHERE "Reference" LIKE '%cristin/%'; -UPDATE public."Grant" -SET "Reference" = CONCAT('OpenAIRE:', "Reference") -where "Reference" like '%_________::%' and -"Reference" not like 'OpenAIRE:%'; - --- Funder -UPDATE public."Funder" -SET "Reference" = CONCAT('cristin:', "Reference") -WHERE "Reference" LIKE '%cristin/%'; -UPDATE public."Funder" -SET "Reference" = CONCAT('openaire:', "Reference") -WHERE "Reference" LIKE '%_________::%' and -upper("Reference") NOT LIKE upper('openAIRE:%'); - --- Project -UPDATE public."Project" -SET "Reference" = CONCAT('cristin:', "Reference") -WHERE "Reference" LIKE '%cristin/%'; -UPDATE public."Project" -SET "Reference" = CONCAT('openaire:', "Reference") -WHERE "Reference" LIKE '%_________::%' and -upper("Reference") NOT LIKE upper('openAIRE:%'); \ No newline at end of file diff --git a/dmp-db-scema/updates/06/01_Update_Dataset_Statuses_To_Canceled_For_Old_Cases.sql b/dmp-db-scema/updates/06/01_Update_Dataset_Statuses_To_Canceled_For_Old_Cases.sql deleted file mode 100644 index 9809fbbdb..000000000 --- a/dmp-db-scema/updates/06/01_Update_Dataset_Statuses_To_Canceled_For_Old_Cases.sql +++ /dev/null @@ -1,8 +0,0 @@ -UPDATE "Dataset" AS dataset -SET "Status" = 2 -WHERE dataset."ID" in ( - SELECT dataset1."ID" - FROM "Dataset" AS dataset1 - INNER JOIN "DMP" AS dmp ON dmp."ID" = dataset1."DMP" - WHERE dmp."isPublic" = true AND dataset1."Status" = 0 -) \ No newline at end of file diff --git a/dmp-db-scema/updates/06/02_Update_Funder_Grant_Project_References_For_Internal_Items.sql b/dmp-db-scema/updates/06/02_Update_Funder_Grant_Project_References_For_Internal_Items.sql deleted file mode 100644 index 6fe80768b..000000000 --- a/dmp-db-scema/updates/06/02_Update_Funder_Grant_Project_References_For_Internal_Items.sql +++ /dev/null @@ -1,11 +0,0 @@ -UPDATE "Funder" -SET "Reference" = CONCAT('dmp:', "ID") -WHERE "Reference" LIKE 'dmp:%'; - -UPDATE "Grant" -SET "Reference" = CONCAT('dmp:', "ID") -WHERE "Reference" LIKE 'dmp:%'; - -UPDATE "Project" -SET "Reference" = CONCAT('dmp:', "ID") -WHERE "Reference" LIKE 'dmp:%'; \ No newline at end of file diff --git a/dmp-db-scema/updates/06/03_Update_Researcher_Internal_Entities_Reference.sql b/dmp-db-scema/updates/06/03_Update_Researcher_Internal_Entities_Reference.sql deleted file mode 100644 index 080cf05d7..000000000 --- a/dmp-db-scema/updates/06/03_Update_Researcher_Internal_Entities_Reference.sql +++ /dev/null @@ -1,6 +0,0 @@ -UPDATE "Researcher" -SET "Reference" = CONCAT('dmp:', "ID") -WHERE "ID" IN ( - SELECT "ID" FROM "Researcher" - WHERE "Reference" LIKE 'dmp:%' -) \ No newline at end of file diff --git a/dmp-db-scema/updates/07/01_Add_Lock_Table_To_Prevent_Parallel_Edits.sql b/dmp-db-scema/updates/07/01_Add_Lock_Table_To_Prevent_Parallel_Edits.sql deleted file mode 100644 index 3d69172b3..000000000 --- a/dmp-db-scema/updates/07/01_Add_Lock_Table_To_Prevent_Parallel_Edits.sql +++ /dev/null @@ -1,14 +0,0 @@ -CREATE TABLE public."Lock" ( - id uuid NOT NULL, - "Target" uuid NOT NULL, - "LockedBy" uuid NOT NULL, - "LockedAt" timestamp NOT NULL, - "TouchedAt" timestamp -); - -ALTER TABLE ONLY public."Lock" - ADD CONSTRAINT "Lock_pkey" PRIMARY KEY (id); - -ALTER TABLE ONLY public."Lock" - ADD CONSTRAINT "LockUserReference" FOREIGN KEY ("LockedBy") REFERENCES public."UserInfo"(id); - diff --git a/dmp-db-scema/updates/07/02_Add_Notification_Table.sql b/dmp-db-scema/updates/07/02_Add_Notification_Table.sql deleted file mode 100644 index e5d125455..000000000 --- a/dmp-db-scema/updates/07/02_Add_Notification_Table.sql +++ /dev/null @@ -1,20 +0,0 @@ -CREATE TABLE public."Notification" ( - id uuid NOT NULL, - "UserId" uuid, - "IsActive" integer NOT NULL, - "Type" integer NOT NULL, - "ContactTypeHint" integer, - "ContactHint" character varying, - "Data" character varying, - "NotifyState" integer NOT NULL, - "NotifiedAt" timestamp without time zone, - "RetryCount" integer, - "CreatedAt" timestamp without time zone, - "UpdatedAt" timestamp without time zone -); - -ALTER TABLE ONLY public."Notification" - ADD CONSTRAINT "Notification_pkey" PRIMARY KEY (id); - -ALTER TABLE ONLY public."Notification" - ADD CONSTRAINT "NotificationUserReference" FOREIGN KEY ("UserId") REFERENCES public."UserInfo"(id); diff --git a/dmp-db-scema/updates/08/01_Add_database_versioning.sql b/dmp-db-scema/updates/08/01_Add_database_versioning.sql deleted file mode 100644 index 47e855bed..000000000 --- a/dmp-db-scema/updates/08/01_Add_database_versioning.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE public."DBVersion" ( - key character varying NOT NULL, - version character varying NOT NULL, - "releasedAt" timestamp with time zone NOT NULL, - "deployedAt" timestamp with time zone, - description text -); - -INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.00.001', '2020-03-31 11:34:54.236152+03', now(), 'Add Database Versioning'); - diff --git a/dmp-db-scema/updates/08/02_Add_missing_columns.sql b/dmp-db-scema/updates/08/02_Add_missing_columns.sql deleted file mode 100644 index 2cecd31cb..000000000 --- a/dmp-db-scema/updates/08/02_Add_missing_columns.sql +++ /dev/null @@ -1,23 +0,0 @@ -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; - -ALTER TABLE public."DatasetDataRepository" -ADD COLUMN "Data" character varying; - -ALTER TABLE public."DatasetService" -ADD COLUMN "Data" character varying; \ 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 deleted file mode 100644 index a2105b72c..000000000 --- a/dmp-db-scema/updates/08/03_Create_Credentials.sql +++ /dev/null @@ -1,25 +0,0 @@ -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 :POSTGRES_USER; - -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_USERNAME'), 'dmp'); - diff --git a/dmp-db-scema/updates/08/04_Create_UserToken.sql b/dmp-db-scema/updates/08/04_Create_UserToken.sql deleted file mode 100644 index 1e129b9d2..000000000 --- a/dmp-db-scema/updates/08/04_Create_UserToken.sql +++ /dev/null @@ -1,16 +0,0 @@ -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 :POSTGRES_USER; - -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 deleted file mode 100644 index 84229bab6..000000000 --- a/dmp-db-scema/updates/08/05_Create_UserRole.sql +++ /dev/null @@ -1,18 +0,0 @@ -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 :POSTGRES_USER; - -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 deleted file mode 100644 index 5ed59655c..000000000 --- a/dmp-db-scema/updates/08/06_Remove_UserAuth.sql +++ /dev/null @@ -1 +0,0 @@ -DROP TABLE IF EXISTS "UserAuth" CASCADE; \ No newline at end of file diff --git a/dmp-db-scema/updates/08/07_Remove_no_null_requirement.sql b/dmp-db-scema/updates/08/07_Remove_no_null_requirement.sql deleted file mode 100644 index 8cda5cf9c..000000000 --- a/dmp-db-scema/updates/08/07_Remove_no_null_requirement.sql +++ /dev/null @@ -1,2 +0,0 @@ -AlTER TABLE "DMP" -ALTER COLUMN "Creator" DROP NOT NULL; \ No newline at end of file diff --git a/dmp-db-scema/updates/08/08_create_datasetexternaldataset.sql b/dmp-db-scema/updates/08/08_create_datasetexternaldataset.sql deleted file mode 100644 index d662b0e80..000000000 --- a/dmp-db-scema/updates/08/08_create_datasetexternaldataset.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE TABLE public."DatasetExternalDataset" ( - "Id" uuid DEFAULT public.uuid_generate_v4() NOT NULL, - "Dataset" uuid NOT NULL, - "ExternalDataset" uuid NOT NULL, - "Role" numeric, - "Data" character varying -); - -ALTER TABLE public."DatasetExternalDataset" OWNER TO :POSTGRES_USER; - -ALTER TABLE ONLY public."DatasetExternalDataset" - ADD CONSTRAINT "DatasetExternalDataset_pkey" PRIMARY KEY ("Id"); - -ALTER TABLE ONLY public."DatasetExternalDataset" - ADD CONSTRAINT fkey_datasetexternaldataset_dataset FOREIGN KEY ("Dataset") REFERENCES public."Dataset"("ID"); - -ALTER TABLE ONLY public."DatasetExternalDataset" - ADD CONSTRAINT fkey_datasetexternaldataset_externaldataset FOREIGN KEY ("ExternalDataset") REFERENCES public."ExternalDataset"("Id"); - diff --git a/dmp-db-scema/updates/08/09_Create_Invitation.sql b/dmp-db-scema/updates/08/09_Create_Invitation.sql deleted file mode 100644 index e61e17f03..000000000 --- a/dmp-db-scema/updates/08/09_Create_Invitation.sql +++ /dev/null @@ -1,23 +0,0 @@ -CREATE TABLE public."Invitation" ( - "Id" uuid NOT NULL, - "InvitationEmail" character varying NOT NULL, - "Token" uuid NOT NULL, - "CreationUser" uuid NOT NULL, - "Dmp" uuid NOT NULL, - "Properties" xml, - "AcceptedInvitation" boolean -); - - -ALTER TABLE public."Invitation" OWNER TO :POSTGRES_USER; - -ALTER TABLE ONLY public."Invitation" - ADD CONSTRAINT "Invitation_pkey" PRIMARY KEY ("Id"); - - -ALTER TABLE ONLY public."Invitation" - ADD CONSTRAINT fk_invitation_creator FOREIGN KEY ("CreationUser") REFERENCES public."UserInfo"(id); - - -ALTER TABLE ONLY public."Invitation" - ADD CONSTRAINT fk_invitation_dmp FOREIGN KEY ("Dmp") REFERENCES public."DMP"("ID"); \ No newline at end of file diff --git a/dmp-db-scema/updates/08/10_Create_User_preference.sql b/dmp-db-scema/updates/08/10_Create_User_preference.sql deleted file mode 100644 index cc5053684..000000000 --- a/dmp-db-scema/updates/08/10_Create_User_preference.sql +++ /dev/null @@ -1,16 +0,0 @@ -CREATE TABLE public."UserPreference" ( - "Id" uuid NOT NULL, - "UserId" uuid NOT NULL, - "Data" json NOT NULL, - "PreferenceType" smallint NOT NULL -); - - -ALTER TABLE public."UserPreference" OWNER TO :POSTGRES_USER; - -ALTER TABLE ONLY public."UserPreference" - ADD CONSTRAINT "UserPreference_pkey" PRIMARY KEY ("Id"); - - -ALTER TABLE ONLY public."UserPreference" - ADD CONSTRAINT userpreference_user_fk FOREIGN KEY ("UserId") REFERENCES public."UserInfo"(id);