| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: project_usage.install,v 1.11 2009/08/03 18:25:15 dww Exp $ 3 4 function project_usage_install() { 5 // Create the database tables. 6 drupal_install_schema('project_usage'); 7 } 8 9 function project_usage_uninstall() { 10 // Drop database tables. 11 drupal_uninstall_schema('project_usage'); 12 13 $variables = array( 14 'project_usage_last_daily', 15 'project_usage_last_weekly', 16 'project_usage_active_weeks', 17 'project_usage_life_daily', 18 'project_usage_life_weekly_project', 19 'project_usage_life_weekly_release', 20 'project_usage_date_long', 21 'project_usage_date_short', 22 ); 23 foreach ($variables as $variable) { 24 variable_del($variable); 25 } 26 } 27 28 /** 29 * Implementation of hook_schema(). 30 */ 31 function project_usage_schema() { 32 $schema['project_usage_raw'] = array( 33 'description' => 'Table used to store raw usage information.', 34 'fields' => array( 35 'project_uri' => array( 36 'description' => 'Primary Key: The {project_projects}.uri short name of the project.', 37 'type' => 'varchar', 38 'length' => 50, 39 'not null' => TRUE, 40 'default' => '', 41 ), 42 'timestamp' => array( 43 'description' => 'Primary Key: The Unix timestamp of when the request was made.', 44 'type' => 'int', 45 'unsigned' => TRUE, 46 'not null' => TRUE, 47 'default' => 0, 48 ), 49 'site_key' => array( 50 'description' => 'Primary Key: An MD5 hash that identifies the site from which the request was made.', 51 'type' => 'varchar', 52 'length' => 32, 53 'not null' => TRUE, 54 'default' => '', 55 ), 56 'api_version' => array( 57 'description' => 'The {term_data}.name of the API version requested.', 58 'type' => 'varchar', 59 'length' => 32, 60 'not null' => TRUE, 61 'default' => '', 62 ), 63 'project_version' => array( 64 'description' => 'The {project_release_nodes}.version of the requested project.', 65 'type' => 'varchar', 66 'length' => 255, 67 'not null' => TRUE, 68 'default' => '', 69 ), 70 'pid' => array( 71 'description' => 'The {node}.nid of the requested project.', 72 'type' => 'int', 73 'unsigned' => TRUE, 74 'not null' => TRUE, 75 'default' => 0, 76 ), 77 'nid' => array( 78 'description' => 'The {node}.nid of the requested release.', 79 'type' => 'int', 80 'unsigned' => TRUE, 81 'not null' => TRUE, 82 'default' => 0, 83 ), 84 'tid' => array( 85 'description' => 'The {term_data}.tid of the API compatability version of the requested release.', 86 'type' => 'int', 87 'unsigned' => TRUE, 88 'not null' => TRUE, 89 'default' => 0, 90 ), 91 'ip_addr' => array( 92 'description' => 'The IP address of the incoming request (to detect possible abuse).', 93 'type' => 'varchar', 94 'length' => 128, 95 'not null' => TRUE, 96 'default' => '', 97 ), 98 ), 99 'primary key' => array('timestamp', 'project_uri', 'site_key'), 100 ); 101 102 $schema['project_usage_day'] = array( 103 'description' => 'Table used to store daily usage information.', 104 'fields' => array( 105 'timestamp' => array( 106 'description' => 'Primary Key: The Unix timestamp of when the request was made.', 107 'type' => 'int', 108 'unsigned' => TRUE, 109 'not null' => TRUE, 110 'default' => 0, 111 ), 112 'site_key' => array( 113 'description' => 'Primary Key: An MD5 hash that identifies the site from which the request was made.', 114 'type' => 'varchar', 115 'length' => 32, 116 'not null' => TRUE, 117 'default' => '', 118 ), 119 'pid' => array( 120 'description' => 'Primary Key: The {node}.nid of the requested project.', 121 'type' => 'int', 122 'unsigned' => TRUE, 123 'not null' => TRUE, 124 'default' => 0, 125 ), 126 'nid' => array( 127 'description' => 'The {node}.nid of the requested release.', 128 'type' => 'int', 129 'unsigned' => TRUE, 130 'not null' => TRUE, 131 'default' => 0, 132 ), 133 'tid' => array( 134 'description' => 'The {term_data}.tid of the API compatability version of the requested release.', 135 'type' => 'int', 136 'unsigned' => TRUE, 137 'not null' => TRUE, 138 'default' => 0, 139 ), 140 'ip_addr' => array( 141 'description' => 'The IP address of the incoming request (to detect possible abuse).', 142 'type' => 'varchar', 143 'length' => 128, 144 'not null' => TRUE, 145 'default' => '', 146 ), 147 ), 148 'primary key' => array('timestamp', 'site_key', 'pid'), 149 ); 150 151 $schema['project_usage_week_project'] = array( 152 'description' => 'Table used to store weekly usage information by project and {term_data}.tid.', 153 'fields' => array( 154 'nid' => array( 155 'description' => 'Primary Key: The {node}.nid of the project.', 156 'type' => 'int', 157 'unsigned' => TRUE, 158 'not null' => TRUE, 159 'default' => 0, 160 ), 161 'timestamp' => array( 162 'description' => 'Primary Key: A Unix timestamp.', 163 'type' => 'int', 164 'unsigned' => TRUE, 165 'not null' => TRUE, 166 'default' => 0, 167 ), 168 'tid' => array( 169 'description' => 'Primary Key: The {term_data}.tid of the API compatability version of the release.', 170 'type' => 'int', 171 'unsigned' => TRUE, 172 'not null' => TRUE, 173 'default' => 0, 174 ), 175 'count' => array( 176 'description' => 'The number of requests.', 177 'type' => 'int', 178 'unsigned' => TRUE, 179 'not null' => TRUE, 180 'default' => 0, 181 ), 182 ), 183 'primary key' => array('nid', 'timestamp', 'tid'), 184 ); 185 186 $schema['project_usage_week_release'] = array( 187 'description' => 'Table used to store weekly usage information by project and {term_data}.tid.', 188 'fields' => array( 189 'nid' => array( 190 'description' => 'Primary Key: The {node}.nid of the project.', 191 'type' => 'int', 192 'unsigned' => TRUE, 193 'not null' => TRUE, 194 'default' => 0, 195 ), 196 'timestamp' => array( 197 'description' => 'Primary Key: A Unix timestamp.', 198 'type' => 'int', 199 'unsigned' => TRUE, 200 'not null' => TRUE, 201 'default' => 0, 202 ), 203 'count' => array( 204 'description' => 'The number of requests.', 205 'type' => 'int', 206 'unsigned' => TRUE, 207 'not null' => TRUE, 208 'default' => 0, 209 ), 210 ), 211 'primary key' => array('nid', 'timestamp'), 212 ); 213 214 $schema['cache_project_usage'] = array( 215 'description' => 'Cache table for the (very expensive to generate) project usage display pages.', 216 'fields' => array( 217 'cid' => array( 218 'description' => 'Primary Key: Unique cache ID.', 219 'type' => 'varchar', 220 'length' => 255, 221 'not null' => TRUE, 222 'default' => '', 223 ), 224 'data' => array( 225 'description' => 'The rendered HTML for a page of project usage data.', 226 'type' => 'blob', 227 'not null' => FALSE, 228 'size' => 'big', 229 ), 230 'expire' => array( 231 'description' => 'A Unix timestamp indicating when the cache entry should expire, or 0 for never.', 232 'type' => 'int', 233 'not null' => TRUE, 234 'default' => 0, 235 ), 236 'created' => array( 237 'description' => 'A Unix timestamp indicating when the cache entry was created.', 238 'type' => 'int', 239 'not null' => TRUE, 240 'default' => 0, 241 ), 242 'headers' => array( 243 'description' => 'Any custom HTTP headers to be added to cached data.', 244 'type' => 'text', 245 'not null' => FALSE, 246 ), 247 'serialized' => array( 248 'description' => 'A flag to indicate whether content is serialized (1) or not (0).', 249 'type' => 'int', 250 'size' => 'small', 251 'not null' => TRUE, 252 'default' => 0, 253 ), 254 ), 255 'indexes' => array('expire' => array('expire')), 256 'primary key' => array('cid'), 257 ); 258 259 return $schema; 260 } 261 262 /** 263 * Add the 'serialized' field to {cache_project_usage}. 264 */ 265 function project_usage_update_6000() { 266 $ret = array(); 267 $spec = array( 268 'type' => 'int', 269 'size' => 'small', 270 'default' => 0, 271 'not null' => TRUE, 272 ); 273 db_add_field($ret, 'cache_project_usage', 'serialized', $spec); 274 return $ret; 275 } 276
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |