session_api.install
1.55 KB
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
<?php
/**
* Implement hook_schema().
*/
function session_api_schema() {
$schema['session_api'] = array(
'description' => t('Map Session API IDs to the {sessions} sid field.'),
'fields' => array(
'sid' => array(
'type' => 'serial',
'not null' => TRUE,
),
'session_id' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
),
'timestamp' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array('sid'),
'unique keys' => array(
'session_id' => array('session_id'),
),
'indexes' => array(
'timestamp' => array('timestamp'),
),
);
return $schema;
}
/**
* Remove cleanup variables.
*/
function session_api_update_6100() {
$ret = array();
$ret[] = update_sql("DELETE FROM {variable} WHERE name LIKE 'session_api_run_cron_%'");
return $ret;
}
/**
* Implementation of hook_update_N().
*
* Adds timestamp field.
*/
function session_api_update_7101() {
db_add_field('session_api', 'timestamp', array('type' => 'int', 'not null' => TRUE, 'default' => 0));
db_add_index('session_api', 'timestamp', array('timestamp'));
return t('Added a timestamp field and index to the session_api table.');
}
/**
* Implements hook_update_N().
*
* Lengthens the session_id field to match core {sessions}.sid field.
*/
function session_api_update_7102() {
db_change_field('session_api', 'session_id', 'session_id', array('type' => 'varchar', 'length' => 128, 'not null' => TRUE));
}