-- add column subnet.reachable
BEGIN;

CREATE or REPLACE FUNCTION  add_subnet_reachable() RETURNS integer AS '
  BEGIN
    IF SPLIT_PART(VERSION(), '' '', 2) = ''7.4.7''
    THEN
      alter table subnet add column reachable varchar(3);
      update subnet set reachable = ''yes'' where reachable is null;
      alter table subnet alter subnet_reachable set default ''yes'';
      alter table subnet alter subnet_reachable set not null;
    ELSE
      alter table subnet add column reachable varchar(3) not null default ''yes'';
    END IF;
    RETURN 0;
  END;
' LANGUAGE plpgsql;

select add_subnet_reachable(); 
      
DROP FUNCTION add_subnet_reachable();
COMMIT;


