DO $$ 
BEGIN
		BEGIN
			IF EXISTS (SELECT "Id" FROM public."Versions" WHERE "Build">=3296) THEN
				RETURN;
		END IF;
		  
		ALTER TABLE public."Contacts" ADD "ExternalIdNew" character varying(2048);
		
		UPDATE public."Contacts" SET "ExternalIdNew" = "ExternalId";
		ALTER TABLE public."Contacts" DROP "ExternalId";
		ALTER TABLE public."Contacts" RENAME "ExternalIdNew" TO "ExternalId";
		
		CREATE INDEX "ix_Contacts_ExternalId"
    	ON public."Contacts" USING btree
    	("ExternalId" COLLATE pg_catalog."default" ASC NULLS LAST)
    	TABLESPACE pg_default;
		
		EXCEPTION
            WHEN OTHERS THEN RAISE NOTICE 'Alter table <Contacts> error.';
        END;
   
END$$
