-
Notifications
You must be signed in to change notification settings - Fork 0
/
d2dsearch.install
144 lines (142 loc) · 4.09 KB
/
d2dsearch.install
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
/**
* @file
* Installation file for D2D Search.
*/
require_once 'includes/d2dsearch.constants.inc';
/**
* Implements hook_install()
*/
function d2dsearch_install() {
$result = db_query('SELECT id FROM {d2d_groups} WHERE name=:name', array(':name' => 'friends'));
if ($row = $result->fetchAssoc()) {
$group_id = $row['id'];
foreach (array('d2dsearch_process_query', 'd2dsearch_process_result') as $method_name) {
try { // try-catch to avoid problems with duplicates on re-installation
$m_id = db_insert('d2d_permissions')->fields(array(
'group_id' => $group_id,
'method' => $method_name,
))->execute();
}
catch (Exception $e) {
}
}
}
}
/**
* Implements hook_uninstall()
*/
function d2dsearch_uninstall() {
drupal_uninstall_schema('d2dsearch_schema');
}
/**
* Implements hook_schema()
*/
function d2dsearch_schema() {
$schema = array();
$schema['d2dsearch_query_cache'] = array(
'description' => 'Stores information on queries being processed.',
'fields' => array(
'qid' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'primary identifier (local id)',
),
'query_id' => array(
'type' => 'varchar',
'length' => D2DSEARCH_QUERY_ID_LENGTH,
'not null' => TRUE,
'description' => 'global query id',
),
'type' => array(
'type' => 'varchar',
'length' => D2DSEARCH_QUERY_TYPE_MAX_LENGTH,
'not null' => TRUE,
'description' => 'type of the query',
),
'query' => array(
'type' => 'varchar',
'length' => D2DSEARCH_QUERY_MAX_LENGTH,
'not null' => TRUE,
'description' => 'the query itself',
),
'instance_id' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'id of instance from which this query was received (last hop)',
),
'timestamp' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'time this query was inserted',
),
),
'primary key' => array('qid'),
'unique keys' => array('query_id' => array('query_id')),
);
$schema['d2dsearch_query_batch'] = array(
'description' => 'Stores information on queries to be forwarded.',
'fields' => array(
'id' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'primary identifier',
),
'qid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'qid of the query (primary identifier in the d2dsearch_query_cache table)',
),
'instance_id' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'id of instance to which this query will be forwarded',
),
),
'primary key' => array('id'),
);
$schema['d2dsearch_result_cache'] = array(
'description' => 'Stores information on results of queries.',
'fields' => array(
'id' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'primary identifier',
),
'qid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'qid of the query (primary identifier in the d2dsearch_query_cache table)',
),
'instance_id' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'id of instance from which this result was received (last hop)',
),
'result' => array(
'type' => 'blob',
'not null' => TRUE,
'description' => 'the result itself',
),
'timestamp' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'time this query was inserted',
),
),
'primary key' => array('id'),
);
return $schema;
}