DO $$ 
    BEGIN
          IF EXISTS (SELECT "Id" FROM public."Versions" WHERE "Build">=1765) THEN
		RETURN;
          END IF;
        BEGIN
           CREATE INDEX "IDX_EmailMessages_FolderId"
    ON public."EmailMessages" USING btree
    ("FolderId" ASC NULLS LAST)
    TABLESPACE pg_default;  

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

CREATE INDEX "IDX_EmailMessages_OwnerId"
    ON public."EmailMessages" USING btree
    ("OwnerId" ASC NULLS LAST)
    TABLESPACE pg_default;  
        EXCEPTION
            WHEN duplicate_table THEN RAISE NOTICE 'Created index already exists in <EmailMessages>.';
        END;
    END;
$$

