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

INSERT INTO object_settings_type(_otype, key, name, descr, type, min_value, max_value)
                         VALUES (3, 'DeviceBusy', 'Device busy', 'Device busy period', 'int', '0', '60000');
INSERT INTO object_settings_type(_otype, key, name, descr, type, min_value, max_value)
                         VALUES (3, 'DownlinkProgram', 'Downlink program', 'Downlink program json', 'string', '', '');

PERFORM objects_add_setting(3, 'DeviceBusy', '30000');
PERFORM objects_add_setting(3, 'DownlinkProgram', '');

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