You are here

function apachesolr_update_7000 in Apache Solr Search 8

Same name and namespace in other branches
  1. 7 apachesolr.install \apachesolr_update_7000()

Add a table to track Solr servers.

File

./apachesolr.install, line 290
Install and related hooks for apachesolr_search.

Code

function apachesolr_update_7000() {
  if (variable_get('apachesolr_update_from_6303', FALSE)) {
    return NULL;
  }
  $schema['apachesolr_server'] = array(
    'description' => 'The Solr server table.',
    'fields' => array(
      'server_id' => array(
        'description' => 'Unique identifier for the server',
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
      ),
      'name' => array(
        'description' => 'Human-readable name for the server',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'scheme' => array(
        'description' => 'Preferred scheme for the registered server',
        'type' => 'varchar',
        'length' => 10,
        'not null' => TRUE,
        'default' => 'http',
      ),
      'host' => array(
        'description' => 'Host name for the registered server',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'port' => array(
        'description' => 'Port number for the registered server',
        'type' => 'int',
        'not null' => TRUE,
      ),
      'path' => array(
        'description' => 'Path to the registered server',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'service_class' => array(
        'description' => 'Optional class name to use for connection',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
    ),
    'primary key' => array(
      'server_id',
    ),
  );
  db_create_table('apachesolr_server', $schema['apachesolr_server']);

  // Insert into the table the current single server record.
  $host = variable_get('apachesolr_host', 'localhost');
  $port = variable_get('apachesolr_port', '8983');
  $path = variable_get('apachesolr_path', '/solr');
  db_insert('apachesolr_server')
    ->fields(array(
    'server_id' => 'solr',
    'name' => 'Apache Solr server',
    'host' => $host,
    'port' => $port,
    'path' => $path,
  ))
    ->execute();
  variable_set('apachesolr_default_server', 'solr');
  variable_del('apachesolr_host');
  variable_del('apachesolr_port');
  variable_del('apachesolr_path');
  $value = variable_get('apachesolr_service_class', NULL);
  if (is_array($value)) {
    list($module, $filepath, $class) = $value;
    variable_set('apachesolr_service_class', $class);
  }
  variable_del('apachesolr_logging');
}