You are here

function apachesolr_update_7005 in Apache Solr Search 8

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

Re-jigger the schema to use just a url column.

File

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

Code

function apachesolr_update_7005() {
  if (variable_get('apachesolr_update_from_6303', FALSE)) {
    return NULL;
  }
  if (db_field_exists('apachesolr_server', 'port')) {

    // You installed the beta3 and need to be fixed up.
    $servers = db_query('SELECT * FROM {apachesolr_server}')
      ->fetchAllAssoc('server_id', PDO::FETCH_ASSOC);
    db_drop_field('apachesolr_server', 'scheme');
    db_drop_field('apachesolr_server', 'port');
    db_drop_field('apachesolr_server', 'path');
    db_change_field('apachesolr_server', 'host', 'url', array(
      'description' => 'Full url for the server',
      'type' => 'varchar',
      'length' => 1000,
      'not null' => TRUE,
    ));
    foreach ($servers as $id => $server) {
      $port = $server['port'] ? ':' . $server['port'] : '';
      $url = $server['scheme'] . '://' . $server['host'] . $port . $server['path'];
      db_update('apachesolr_server')
        ->fields(array(
        'url' => $url,
      ))
        ->condition('server_id', $id)
        ->execute();
    }
  }
}