DO $$ 
    BEGIN
          IF EXISTS (SELECT "Id" FROM public."Versions" WHERE "Build">=1765) THEN
		RETURN;
          END IF;
        BEGIN
            ALTER TABLE public."UserEmails" ADD "ImapServer" character varying(500) NULL;
ALTER TABLE public."UserEmails" ADD    "ImapConnectionType" int not null DEFAULT 0;
ALTER TABLE public."UserEmails" ADD    "ImapPort" INT NOT NULL DEFAULT 143;
ALTER TABLE public."UserEmails" ADD    "SmtpServer" character varying(500) NULL;
ALTER TABLE public."UserEmails" ADD    "SmtpPort" INT NOT NULL DEFAULT 587;
ALTER TABLE public."UserEmails" ADD   "SmtpConnectionType" int not null DEFAULT 0;
ALTER TABLE public."UserEmails" ADD    "PopServer" character varying(500)  NULL;
ALTER TABLE public."UserEmails" ADD    "PopPort" INT NOT NULL DEFAULT 995;
ALTER TABLE public."UserEmails" ADD    "PopConnectionType" int not null DEFAULT 0;
ALTER TABLE public."UserEmails" ADD "ServerId" bigint NULL;
ALTER table public."EmailServers"  ADD  "SmtpConnectionType" int not null DEFAULT 0;
ALTER table public."EmailServers"  ADD   "PopConnectionType" int not null DEFAULT 0;
ALTER table public."EmailServers"  ADD  "ImapConnectionType" int not null DEFAULT 0;
        EXCEPTION
            WHEN duplicate_column THEN RAISE NOTICE 'column ImapServer already exists in <UserEmails>.';
        END;
    END;
$$

