Database scripts to move DMP Role to intermediate table, create DMPDatasetprofile, insert Finalized date on DMPs.

This commit is contained in:
gkolokythas 2019-06-07 16:55:10 +03:00
parent cd05187326
commit 5b2b5aaf31
2 changed files with 60 additions and 0 deletions

View File

@ -0,0 +1,60 @@
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;
ALTER TABLE public."UserDMP"
OWNER to dmtadm;
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