From 5d882c7e886d2f8617bc0cc9f4b13624820bdb47 Mon Sep 17 00:00:00 2001 From: Thomas Georgios Giannos Date: Fri, 27 Oct 2023 17:29:22 +0300 Subject: [PATCH] Drop old unused dataset related tables, small fix to migration script --- dmp-db-scema/updates/00.01.005_Add_Dmp_table.sql | 3 ++- .../00.01.009_Drop_old_dataset_related_tables.sql | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 dmp-db-scema/updates/00.01.009_Drop_old_dataset_related_tables.sql diff --git a/dmp-db-scema/updates/00.01.005_Add_Dmp_table.sql b/dmp-db-scema/updates/00.01.005_Add_Dmp_table.sql index 02de486e5..d8c16638c 100644 --- a/dmp-db-scema/updates/00.01.005_Add_Dmp_table.sql +++ b/dmp-db-scema/updates/00.01.005_Add_Dmp_table.sql @@ -21,7 +21,8 @@ CREATE TABLE IF NOT EXISTS public."Dmp" "is_active" smallint NOT NULL DEFAULT 1, "finalized_at" timestamp without time zone, "published_at" timestamp without time zone, - CONSTRAINT "Dmp_pkey" PRIMARY KEY (id) + CONSTRAINT "Dmp_pkey" PRIMARY KEY (id), + CONSTRAINT "Dmp_creator_fkey" FOREIGN KEY (creator) REFERENCES public."UserInfo" (id) ) INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.005', '2023-10-27 12:00:00.000000+02', now(), 'Add Dmp table.'); diff --git a/dmp-db-scema/updates/00.01.009_Drop_old_dataset_related_tables.sql b/dmp-db-scema/updates/00.01.009_Drop_old_dataset_related_tables.sql new file mode 100644 index 000000000..7c210623c --- /dev/null +++ b/dmp-db-scema/updates/00.01.009_Drop_old_dataset_related_tables.sql @@ -0,0 +1,13 @@ +DO $$DECLARE + this_version CONSTANT varchar := '00.01.009'; +BEGIN + PERFORM * FROM "DBVersion" WHERE version = this_version; + IF FOUND THEN RETURN; END IF; + +DROP TABLE public."DatasetProfileViewstyle"; + +DROP TABLE public."DatasetProfileRuleset"; + +INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.009', '2023-10-27 12:00:00.000000+02', now(), 'Drop old dataset related tables.'); + +END$$; \ No newline at end of file