
DO $$DECLARE
   this_version CONSTANT varchar := '00.01.016';
BEGIN
   PERFORM * FROM "DBVersion" WHERE version = this_version;
   IF FOUND THEN RETURN; END IF;

        CREATE TABLE IF NOT EXISTS public."DescriptionTag"
        (
            id uuid NOT NULL,
            description uuid NOT NULL,
            tag uuid NOT NULL,
            is_active smallint NOT NULL,
            created_at timestamp without time zone NOT NULL,
            updated_at timestamp without time zone NOT NULL,
            CONSTRAINT "DescriptionTag_pkey" PRIMARY KEY (id),
            CONSTRAINT "DescriptionTag_description_fkey" FOREIGN KEY (description)
                REFERENCES public."Description" (id) MATCH SIMPLE
                ON UPDATE NO ACTION
                ON DELETE NO ACTION
                NOT VALID,
            CONSTRAINT "DescriptionTag_tag_fkey" FOREIGN KEY (tag)
                REFERENCES public."Tag" (id) MATCH SIMPLE
                ON UPDATE NO ACTION
                ON DELETE NO ACTION
                NOT VALID
        )
        WITH (
            OIDS = FALSE
        )
        TABLESPACE pg_default;

INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.016', '2023-11-20 12:00:00.000000+02', now(), 'Add table DescriptionTag.');

END$$;