DO $$
DECLARE
 version_new_ CONSTANT integer := 25;-- new version number --
 ver_ integer;
BEGIN
  LOCK TABLE variables;
  SELECT version_is('Ls') INTO ver_;
  IF ver_ < version_new_ THEN
    -- begin update --

--- Tcp router --- (31/32/33, 12)	
INSERT INTO object_type (_id, name, descr) VALUES (12, 'udp', 'UDP router');
INSERT INTO object(_id, _otype, guid, name, descr, revision, uri, status) VALUES (31, 12, 'udp', 'UDP router server', 'UDP router server default', 0, '', 0);
INSERT INTO object_connection(_omaster, _oslave, type) VALUES (0, 31, 0);
INSERT INTO object(_id, _otype, guid, name, descr, revision, uri, status) VALUES (32, 12, 'udr', 'UDP Right router client', 'UDP Right router client default', 0, '', 0);
INSERT INTO object_connection(_omaster, _oslave, type) VALUES (0, 32, 0);
INSERT INTO object(_id, _otype, guid, name, descr, revision, uri, status) VALUES (33, 12, 'udl', 'UDP Left router client', 'UDP Left router client default', 0, '', 0);
INSERT INTO object_connection(_omaster, _oslave, type) VALUES (0, 33, 0);

--- Tcp router --- (31/32, 12)
INSERT INTO object_settings_type(_otype, key, name, descr, type, min_value, max_value)
  VALUES (12, 'Type', 'Server', 'Type of router', 'bool', 'client', 'server');
INSERT INTO object_settings_type(_otype, key, name, descr, type, min_value, max_value)
  VALUES (12, 'Port', 'Port', 'Server port', 'int', '1024', '65535');
INSERT INTO object_settings_type(_otype, key, name, descr, type, min_value, max_value)
  VALUES (12, 'PortIn', 'PortIn', 'Client port in', 'int', '1024', '65535');
INSERT INTO object_settings_type(_otype, key, name, descr, type, min_value, max_value)
  VALUES (12, 'PortOut', 'PortOut', 'Client port out', 'int', '1024', '65535');
INSERT INTO object_settings_type(_otype, key, name, descr, type, min_value, max_value)
  VALUES (12, 'LeftOrRight', 'LeftOrRight', 'Left or right client', 'bool', 'left', 'right');
INSERT INTO object_settings_type(_otype, key, name, descr, type, min_value, max_value)
  VALUES (12, 'Host', 'Host', 'Server host name or IP address', 'text', '', '');
INSERT INTO object_settings_type(_otype, key, name, descr, type, min_value, max_value)
  VALUES (12, 'HostPort', 'Host port', 'Server host port', 'int', '1024', '65535');
INSERT INTO object_settings(_object, key, value) VALUES (31, 'Server', '1');
INSERT INTO object_settings(_object, key, value) VALUES (31, 'Port', '25001');
INSERT INTO object_settings(_object, key, value) VALUES (32, 'Server', '0');
INSERT INTO object_settings(_object, key, value) VALUES (32, 'Host', '92.53.102.118');
INSERT INTO object_settings(_object, key, value) VALUES (32, 'HostPort', '25001');
INSERT INTO object_settings(_object, key, value) VALUES (32, 'PortIn', '5000');
INSERT INTO object_settings(_object, key, value) VALUES (32, 'PortOut', '9011');
INSERT INTO object_settings(_object, key, value) VALUES (32, 'LeftOrRight', '1');
INSERT INTO object_settings(_object, key, value) VALUES (33, 'Server', '0');
INSERT INTO object_settings(_object, key, value) VALUES (33, 'Host', '92.53.102.118');
INSERT INTO object_settings(_object, key, value) VALUES (33, 'HostPort', '25001');
INSERT INTO object_settings(_object, key, value) VALUES (33, 'PortIn', '9011');
INSERT INTO object_settings(_object, key, value) VALUES (33, 'PortOut', '5000');
INSERT INTO object_settings(_object, key, value) VALUES (33, 'LeftOrRight', '0');

    -- end update --
    PERFORM version_set('Ls', version_new_);
  END IF;
END$$;