DO $$ 
    BEGIN
          IF EXISTS (SELECT "Id" FROM public."Versions" WHERE "Build">=1765) THEN
		RETURN;
          END IF;
        BEGIN
 		ALTER TABLE public."EmailMessages" ADD "MessageId" character varying(64) NULL;

CREATE INDEX "IDX_EmailMessages_MessageId_Id"
    ON public."EmailMessages" USING btree
    ("MessageId" ASC NULLS LAST,"Id" ASC NULLS LAST)
    TABLESPACE pg_default; 

        EXCEPTION
            WHEN OTHERS THEN RAISE NOTICE 'Alter table <EmailMessages>  error.';
        END;
    END;
$$



