summaryrefslogtreecommitdiff
path: root/modules/search/search.install
blob: 3f2fc48abd711ada0685a31f2abfe6107027d934 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
// $Id$

/**
 * Implementation of hook_install().
 */
function search_install() {
  // Create tables.
  drupal_install_schema('search');
}

/**
 * Implementation of hook_uninstall().
 */
function search_uninstall() {
  // Remove tables.
  drupal_uninstall_schema('search');

  variable_del('minimum_word_size');
  variable_del('overlap_cjk');
  variable_del('search_cron_limit');
}

/**
 * Implementation of hook_schema().
 */
function search_schema() {
  $schema['search_dataset'] = array(
    'fields' => array(
      'sid'  => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
      'type' => array('type' => 'varchar', 'length' => 16, 'not null' => FALSE),
      'data' => array('type' => 'text', 'not null' => TRUE, 'size' => 'big')
    ),
    'indexes' => array('sid_type' => array('sid', 'type')),
  );

  $schema['search_index'] = array(
    'fields' => array(
      'word'     => array('type' => 'varchar', 'length' => 50, 'not null' => TRUE, 'default' => ''),
      'sid'      => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
      'type'     => array('type' => 'varchar', 'length' => 16, 'not null' => FALSE),
      'fromsid'  => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
      'fromtype' => array('type' => 'varchar', 'length' => 16, 'not null' => FALSE),
      'score'    => array('type' => 'float', 'not null' => FALSE)
    ),
    'indexes' => array(
      'from_sid_type' => array('fromsid', 'fromtype'),
      'sid_type'      => array('sid', 'type'),
      'word'          => array('word')
    ),
  );

  $schema['search_total'] = array(
    'fields' => array(
      'word'  => array('type' => 'varchar', 'length' => 50, 'not null' => TRUE, 'default' => ''),
      'count' => array('type' => 'float', 'not null' => FALSE)
    ),
    'primary key' => array('word'),
  );

  return $schema;
}