DO $$ 
    BEGIN
          IF EXISTS (SELECT "Id" FROM public."Versions" WHERE "Build">=1765) THEN
		RETURN;
          END IF;
        BEGIN
            ALTER TABLE public."EmailMessages" ADD     "ParentId" BIGINT NULL;
ALTER TABLE public."EmailMessages" ADD   "HasChildren" boolean DEFAULT false;
        EXCEPTION
            WHEN duplicate_column THEN RAISE NOTICE 'column ParentId already exists in <EmailMessages>.';
        END;
    END;
$$

