| 1 |
<?php
|
| 2 |
// $Id: dblog.install,v 1.18 2009/09/29 15:13:55 dries Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Install, update and uninstall functions for the dblog module.
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Implement hook_schema().
|
| 11 |
*/
|
| 12 |
function dblog_schema() {
|
| 13 |
$schema['watchdog'] = array(
|
| 14 |
'description' => 'Table that contains logs of all system events.',
|
| 15 |
'fields' => array(
|
| 16 |
'wid' => array(
|
| 17 |
'type' => 'serial',
|
| 18 |
'not null' => TRUE,
|
| 19 |
'description' => 'Primary Key: Unique watchdog event ID.',
|
| 20 |
),
|
| 21 |
'uid' => array(
|
| 22 |
'type' => 'int',
|
| 23 |
'not null' => TRUE,
|
| 24 |
'default' => 0,
|
| 25 |
'description' => 'The {users}.uid of the user who triggered the event.',
|
| 26 |
),
|
| 27 |
'type' => array(
|
| 28 |
'type' => 'varchar',
|
| 29 |
'length' => 64,
|
| 30 |
'not null' => TRUE,
|
| 31 |
'default' => '',
|
| 32 |
'description' => 'Type of log message, for example "user" or "page not found."',
|
| 33 |
),
|
| 34 |
'message' => array(
|
| 35 |
'type' => 'text',
|
| 36 |
'not null' => TRUE,
|
| 37 |
'size' => 'big',
|
| 38 |
'description' => 'Text of log message to be passed into the t() function.',
|
| 39 |
),
|
| 40 |
'variables' => array(
|
| 41 |
'type' => 'text',
|
| 42 |
'not null' => TRUE,
|
| 43 |
'size' => 'big',
|
| 44 |
'description' => 'Serialized array of variables that match the message string and that is passed into the t() function.',
|
| 45 |
),
|
| 46 |
'severity' => array(
|
| 47 |
'type' => 'int',
|
| 48 |
'unsigned' => TRUE,
|
| 49 |
'not null' => TRUE,
|
| 50 |
'default' => 0,
|
| 51 |
'size' => 'tiny',
|
| 52 |
'description' => 'The severity level of the event; ranges from 0 (Emergency) to 7 (Debug)',
|
| 53 |
),
|
| 54 |
'link' => array(
|
| 55 |
'type' => 'varchar',
|
| 56 |
'length' => 255,
|
| 57 |
'not null' => FALSE,
|
| 58 |
'default' => '',
|
| 59 |
'description' => 'Link to view the result of the event.',
|
| 60 |
),
|
| 61 |
'location' => array(
|
| 62 |
'type' => 'text',
|
| 63 |
'not null' => TRUE,
|
| 64 |
'description' => 'URL of the origin of the event.',
|
| 65 |
),
|
| 66 |
'referer' => array(
|
| 67 |
'type' => 'text',
|
| 68 |
'not null' => FALSE,
|
| 69 |
'description' => 'URL of referring page.',
|
| 70 |
),
|
| 71 |
'hostname' => array(
|
| 72 |
'type' => 'varchar',
|
| 73 |
'length' => 128,
|
| 74 |
'not null' => TRUE,
|
| 75 |
'default' => '',
|
| 76 |
'description' => 'Hostname of the user who triggered the event.',
|
| 77 |
),
|
| 78 |
'timestamp' => array(
|
| 79 |
'type' => 'int',
|
| 80 |
'not null' => TRUE,
|
| 81 |
'default' => 0,
|
| 82 |
'description' => 'Unix timestamp of when event occurred.',
|
| 83 |
),
|
| 84 |
),
|
| 85 |
'primary key' => array('wid'),
|
| 86 |
'indexes' => array(
|
| 87 |
'type' => array('type'),
|
| 88 |
'uid' => array('uid'),
|
| 89 |
),
|
| 90 |
);
|
| 91 |
|
| 92 |
return $schema;
|
| 93 |
}
|
| 94 |
|
| 95 |
/**
|
| 96 |
* @defgroup updates-6.x-extra Extra database logging updates for 6.x
|
| 97 |
* @{
|
| 98 |
*/
|
| 99 |
|
| 100 |
/**
|
| 101 |
* Allow longer referrers.
|
| 102 |
*/
|
| 103 |
function dblog_update_6000() {
|
| 104 |
db_change_field('watchdog', 'referer', 'referer', array('type' => 'text', 'not null' => FALSE));
|
| 105 |
}
|
| 106 |
|
| 107 |
/**
|
| 108 |
* @} End of "defgroup updates-6.x-extra"
|
| 109 |
* The next series of updates should start at 7000.
|
| 110 |
*/
|
| 111 |
|
| 112 |
|
| 113 |
/**
|
| 114 |
* @defgroup updates-6.x-to-7.x database logging updates from 6.x to 7.x
|
| 115 |
* @{
|
| 116 |
*/
|
| 117 |
|
| 118 |
/**
|
| 119 |
* Allow NULL values for links.
|
| 120 |
*/
|
| 121 |
function dblog_update_7001() {
|
| 122 |
db_change_field('watchdog', 'link', 'link', array('type' => 'varchar', 'length' => 255, 'not null' => FALSE, 'default' => ''));
|
| 123 |
}
|
| 124 |
|
| 125 |
/**
|
| 126 |
* Add index on uid.
|
| 127 |
*/
|
| 128 |
function dblog_update_7002() {
|
| 129 |
db_add_index('watchdog', 'uid', array('uid'));
|
| 130 |
}
|
| 131 |
|
| 132 |
/**
|
| 133 |
* Allow longer type values.
|
| 134 |
*/
|
| 135 |
function dblog_update_7003() {
|
| 136 |
db_change_field('watchdog', 'type', 'type', array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => ''));
|
| 137 |
}
|
| 138 |
|
| 139 |
/**
|
| 140 |
* @} End of "defgroup updates-6.x-to-7.x"
|
| 141 |
* The next series of updates should start at 8000.
|
| 142 |
*/
|