From 6f5fcabc7957c4abecdfa1f7c48bb45b228ad242 Mon Sep 17 00:00:00 2001 From: Aldo Mihasi Date: Tue, 12 Sep 2023 15:24:25 +0300 Subject: [PATCH] add db scripts: inserting default blueprint, attach that blueprint as profile of each dmp, make each dataset section index correspond to the default blueprint last section --- ...olumn_to_Dataset_and_DMPDatasetProfile.sql | 2 +- ...nt_and_add_dmpSectionIndex_to datasets.sql | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 dmp-db-scema/updates/00.00.016_Insert_default_blueprint_and_add_dmpSectionIndex_to datasets.sql diff --git a/dmp-db-scema/updates/00.00.015_Add_new_column_to_Dataset_and_DMPDatasetProfile.sql b/dmp-db-scema/updates/00.00.015_Add_new_column_to_Dataset_and_DMPDatasetProfile.sql index b0cd7df0c..b6729b9fe 100644 --- a/dmp-db-scema/updates/00.00.015_Add_new_column_to_Dataset_and_DMPDatasetProfile.sql +++ b/dmp-db-scema/updates/00.00.015_Add_new_column_to_Dataset_and_DMPDatasetProfile.sql @@ -1,5 +1,5 @@ DO $$DECLARE - this_version CONSTANT varchar := '00.00.014'; + this_version CONSTANT varchar := '00.00.015'; BEGIN PERFORM * FROM "DBVersion" WHERE version = this_version; IF FOUND THEN RETURN; END IF; diff --git a/dmp-db-scema/updates/00.00.016_Insert_default_blueprint_and_add_dmpSectionIndex_to datasets.sql b/dmp-db-scema/updates/00.00.016_Insert_default_blueprint_and_add_dmpSectionIndex_to datasets.sql new file mode 100644 index 000000000..bb61227b6 --- /dev/null +++ b/dmp-db-scema/updates/00.00.016_Insert_default_blueprint_and_add_dmpSectionIndex_to datasets.sql @@ -0,0 +1,20 @@ +DO $$DECLARE + this_version CONSTANT varchar := '00.00.016'; +BEGIN + PERFORM * FROM "DBVersion" WHERE version = this_version; + IF FOUND THEN RETURN; END IF; + +INSERT INTO public."DMPProfile" VALUES ('1374c46d-55b5-472a-8e10-c6ee8c0b5f7f', 'Dmp Default Blueprint', '
',1, now(),now()); +UPDATE public."DMP" SET ("Profile") = '1374c46d-55b5-472a-8e10-c6ee8c0b5f7f' WHERE "Profile" IS NULL; +UPDATE public."Dataset" SET ("DmpSectionIndex") = '3' WHERE "DmpSectionIndex" IS NULL; +UPDATE public."DMPDatasetProfile" SET ("data") = '{"dmpSectionIndex":[3]}' WHERE "data" IS NULL; + +ALTER TABLE public."Dataset" +ALTER COLUMN "DmpSectionIndex" SET NOT NULL; + +ALTER TABLE public."DMPDatasetProfile" +ALTER COLUMN "data" SET NOT NULL; + +INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.00.016', '2023-09-12 12:00:00.000000+02', now(), 'Insert default blueprint, update profile of existing dmps and update DmpSectionIndex for each dataset.'); + +END$$; \ No newline at end of file