search.install 2.4 KB
Newer Older
1
<?php
2
// $Id$
3

4 5 6
/**
 * Implementation of hook_install().
 */
7 8 9 10 11
function search_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {search_dataset} (
12
        sid int unsigned NOT NULL default '0',
13 14 15 16 17 18 19
        type varchar(16) default NULL,
        data longtext NOT NULL,
        KEY sid_type (sid, type)
      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");

      db_query("CREATE TABLE {search_index} (
        word varchar(50) NOT NULL default '',
20
        sid int unsigned NOT NULL default '0',
21
        type varchar(16) default NULL,
22
        fromsid int unsigned NOT NULL default '0',
23 24 25 26 27 28 29 30 31 32 33 34
        fromtype varchar(16) default NULL,
        score float default NULL,
        KEY sid_type (sid, type),
        KEY from_sid_type (fromsid, fromtype),
        KEY word (word)
      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");

      db_query("CREATE TABLE {search_total} (
        word varchar(50) NOT NULL default '',
        count float default NULL,
        PRIMARY KEY (word)
      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
35 36 37
      break;
    case 'pgsql':
      db_query("CREATE TABLE {search_dataset} (
38
        sid int_unsigned NOT NULL default '0',
39 40 41 42 43 44 45
        type varchar(16) default NULL,
        data text NOT NULL
      )");
      db_query("CREATE INDEX {search_dataset}_sid_type_idx ON {search_dataset} (sid, type)");

      db_query("CREATE TABLE {search_index} (
        word varchar(50) NOT NULL default '',
46
        sid int_unsigned NOT NULL default '0',
47
        type varchar(16) default NULL,
48
        fromsid int_unsigned NOT NULL default '0',
49 50 51 52 53 54 55 56 57 58 59 60 61
        fromtype varchar(16) default NULL,
        score float default NULL
      )");
      db_query("CREATE INDEX {search_index}_sid_type_idx ON {search_index} (sid, type)");
      db_query("CREATE INDEX {search_index}_from_sid_type_idx ON {search_index} (fromsid, fromtype)");
      db_query("CREATE INDEX {search_index}_word_idx ON {search_index} (word)");

      db_query("CREATE TABLE {search_total} (
        word varchar(50) NOT NULL default '',
        count float default NULL,
        PRIMARY KEY (word)
      )");
      break;
62
  }
63
}
64 65 66 67 68 69 70 71 72 73

/**
 * Implementation of hook_uninstall().
 */
function search_uninstall() {
  db_query('DROP TABLE {search_dataset}');
  db_query('DROP TABLE {search_index}');
  db_query('DROP TABLE {search_total}');
  variable_del('minimum_word_size');
  variable_del('overlap_cjk');
74
  variable_del('search_cron_limit');
75
}