diff --git a/dmp-db-scema/updates/00.01.047_Add_versioning_on_dmp_blueprint.sql b/dmp-db-scema/updates/00.01.047_Add_versioning_on_dmp_blueprint.sql new file mode 100644 index 000000000..5b01b277c --- /dev/null +++ b/dmp-db-scema/updates/00.01.047_Add_versioning_on_dmp_blueprint.sql @@ -0,0 +1,22 @@ +DO $$DECLARE + this_version CONSTANT varchar := '00.01.047'; +BEGIN + PERFORM * FROM "DBVersion" WHERE version = this_version; + IF FOUND THEN RETURN; END IF; + +ALTER TABLE public."DmpBlueprint" ADD COLUMN "group_id" uuid; +UPDATE public."DmpBlueprint" SET "group_id" = uuid_generate_v4(); +ALTER TABLE public."DmpBlueprint" ALTER COLUMN "group_id" SET NOT NULL; + +ALTER TABLE public."DmpBlueprint" ADD COLUMN "version" integer; +UPDATE public."DmpBlueprint" SET "version" = 1; +ALTER TABLE public."DmpBlueprint" ALTER COLUMN "version" SET NOT NULL; + +ALTER TABLE public."DmpBlueprint" ADD COLUMN "version_status" smallint; +UPDATE public."DmpBlueprint" SET "version_status" = 2 where "status" = 0; +UPDATE public."DmpBlueprint" SET "version_status" = 0 where "status" = 1; +ALTER TABLE public."DmpBlueprint" ALTER COLUMN "version_status" SET NOT NULL; + +INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.047', '2024-02-02 12:00:00.000000+02', now(), 'Add versioning on dmp blueprint table.'); + +END$$; \ No newline at end of file