argos/dmp-db-scema/updates/00.01.004_Align_Dmp_bluepri...

36 lines
1.2 KiB
MySQL
Raw Normal View History

DO $$DECLARE
this_version CONSTANT varchar := '00.01.004';
BEGIN
PERFORM * FROM "DBVersion" WHERE version = this_version;
IF FOUND THEN RETURN; END IF;
2023-10-20 18:13:57 +02:00
ALTER TABLE public."DMPProfile" RENAME TO "DmpBlueprint";
ALTER TABLE public."DmpBlueprint" RENAME "ID" TO id;
ALTER TABLE public."DmpBlueprint" RENAME "Label" TO label;
ALTER TABLE public."DmpBlueprint" RENAME "Definition" TO definition;
ALTER TABLE public."DmpBlueprint" RENAME "Status" TO status;
ALTER TABLE public."DmpBlueprint" RENAME "Created" TO created_at;
ALTER TABLE public."DmpBlueprint" ALTER COLUMN created_at TYPE timestamp without time zone ;
ALTER TABLE public."DmpBlueprint" RENAME "Modified" TO updated_at;
ALTER TABLE public."DmpBlueprint" ALTER COLUMN updated_at TYPE timestamp without time zone ;
ALTER TABLE public."DmpBlueprint" ADD COLUMN is_active smallint;
UPDATE public."DmpBlueprint" SET is_active = 1;
UPDATE public."DmpBlueprint" SET is_active = 0 where status = 99;
UPDATE public."DmpBlueprint" SET status = 0 where is_active = 0;
ALTER TABLE public."DmpBlueprint" ALTER COLUMN is_active SET NOT NULL;
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.004', '2023-10-27 12:00:00.000000+02', now(), 'Align dmp blueprint table.');
END$$;