argos/dmp-db-scema/updates/00.01.014_sync_Description.sql

53 lines
1.7 KiB
MySQL
Raw Permalink Normal View History

2023-11-20 16:08:43 +01:00
DO $$DECLARE
this_version CONSTANT varchar := '00.01.014';
BEGIN
PERFORM * FROM "DBVersion" WHERE version = this_version;
IF FOUND THEN RETURN; END IF;
ALTER TABLE public."Description" DROP CONSTRAINT "Description_profile_fkey";
ALTER TABLE public."Description" DROP COLUMN uri;
ALTER TABLE public."Description" DROP COLUMN profile;
ALTER TABLE public."Description" DROP COLUMN reference;
ALTER TABLE public."Description" DROP COLUMN dmp_section_index;
ALTER TABLE public."Description" ADD COLUMN description_template uuid NOT NULL;
2023-11-20 16:08:43 +01:00
ALTER TABLE public."Description"
ALTER COLUMN dmp SET NOT NULL;
ALTER TABLE public."Description"
ADD COLUMN created_by uuid NOT NULL;
ALTER TABLE public."Description"
ADD COLUMN dmp_description_template uuid NOT NULL;
ALTER TABLE public."Description"
ADD FOREIGN KEY (created_by)
REFERENCES public."UserInfo" (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID;
ALTER TABLE public."Description"
ADD FOREIGN KEY (dmp_description_template)
REFERENCES public."DmpDescriptionTemplate" (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID;
ALTER TABLE public."Description"
ADD FOREIGN KEY (description_template)
REFERENCES public."DescriptionTemplate" (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID;
2023-11-20 16:08:43 +01:00
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.014', '2023-11-20 12:00:00.000000+02', now(), 'Sync table Description.');
END$$;