You are here

function apachesolr_install in Apache Solr Search 5.2

Same name and namespace in other branches
  1. 8 apachesolr.install \apachesolr_install()
  2. 6.3 apachesolr.install \apachesolr_install()
  3. 6 apachesolr.install \apachesolr_install()
  4. 6.2 apachesolr.install \apachesolr_install()
  5. 7 apachesolr.install \apachesolr_install()

Implementation of hook_install().

File

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

Code

function apachesolr_install() {

  // Create tables.
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {apachesolr_search_node} (\n        nid int(10) unsigned NOT NULL COMMENT 'The primary identifier for a node.',\n        status int(11) NOT NULL default 1 COMMENT 'Boolean indicating whether the node is published (visible to non-administrators).',\n        changed int(11) NOT NULL default 0 COMMENT 'The Unix timestamp when a node property was changed.',\n        PRIMARY KEY (nid),\n        KEY changed (changed, status)\n      ) TYPE=MyISAM COMMENT='Stores a record of when a node property changed to determine if it needs indexing by Solr.' /*!40100 DEFAULT CHARACTER SET utf8 */;");
      db_query("CREATE TABLE {cache_apachesolr} (\n        cid varchar(255) NOT NULL default '',\n        data longblob,\n        expire int NOT NULL default '0',\n        created int NOT NULL default '0',\n        headers text,\n        PRIMARY KEY (cid),\n        INDEX expire (expire)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      break;
    case 'pgsql':

      // PostgreSQL DB
      db_query("CREATE TABLE {apachesolr_search_node} (\n        nid numeric(10) NOT NULL default 0,\n        status numeric(11) NOT NULL default 1,\n        changed numeric(11) NOT NULL default 0,\n        PRIMARY KEY (nid)\n      )");
      db_query("CREATE INDEX {apachesolr_search_node}_changed_idx ON {apachesolr_search_node} (changed)");
      drupal_set_message("Created Table: apachesolr_search_node");
      db_query("CREATE TABLE {cache_apachesolr} (\n        cid varchar(255) NOT NULL default '',\n        data bytea,\n        expire numeric(11) NOT NULL default 0,\n        created numeric(11) NOT NULL default 0,\n        headers text,\n        PRIMARY KEY (cid)\n      )");
      db_query("CREATE INDEX {cache_apachesolr}_expire_idx ON {cache_apachesolr} (expire)");
      drupal_set_message("Created Table: cache_apachesolr");
      break;
  }

  // Create one MLT block.
  require_once drupal_get_path('module', 'apachesolr') . '/apachesolr.admin.inc';
  apachesolr_mlt_save_block(array(
    'name' => t('More like this'),
  ));
  drupal_set_message(t('Search is enabled. Your site is <a href="!index_settings_link">currently 0% indexed</a>.', array(
    '!index_settings_link' => url('admin/settings/apachesolr/index'),
  )));
}