[177a560] | 1 | <?php |
---|
| 2 | |
---|
| 3 | /** |
---|
| 4 | * @file |
---|
| 5 | * Schema definitions install/update/uninstall hooks. |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | /** |
---|
| 9 | * Implements hook_schema(). |
---|
| 10 | */ |
---|
| 11 | function feeds_schema() { |
---|
| 12 | $schema = array(); |
---|
| 13 | |
---|
| 14 | $schema['feeds_importer'] = array( |
---|
| 15 | 'description' => 'Configuration of feeds objects.', |
---|
| 16 | 'export' => array( |
---|
| 17 | 'key' => 'id', |
---|
| 18 | 'identifier' => 'feeds_importer', |
---|
| 19 | 'default hook' => 'feeds_importer_default', // Function hook name. |
---|
| 20 | 'api' => array( |
---|
| 21 | 'owner' => 'feeds', |
---|
| 22 | 'api' => 'feeds_importer_default', // Base name for api include files. |
---|
| 23 | 'minimum_version' => 1, |
---|
| 24 | 'current_version' => 1, |
---|
| 25 | ), |
---|
| 26 | ), |
---|
| 27 | 'fields' => array( |
---|
| 28 | 'id' => array( |
---|
| 29 | 'type' => 'varchar', |
---|
| 30 | 'length' => 128, |
---|
| 31 | 'not null' => TRUE, |
---|
| 32 | 'default' => '', |
---|
| 33 | 'description' => 'Id of the fields object.', |
---|
| 34 | ), |
---|
| 35 | 'config' => array( |
---|
| 36 | 'type' => 'text', |
---|
| 37 | 'not null' => FALSE, |
---|
| 38 | 'description' => 'Configuration of the feeds object.', |
---|
| 39 | 'serialize' => TRUE, |
---|
| 40 | ), |
---|
| 41 | ), |
---|
| 42 | 'primary key' => array('id'), |
---|
| 43 | ); |
---|
| 44 | $schema['feeds_source'] = array( |
---|
| 45 | 'description' => 'Source definitions for feeds.', |
---|
| 46 | 'fields' => array( |
---|
| 47 | 'id' => array( |
---|
| 48 | 'type' => 'varchar', |
---|
| 49 | 'length' => 128, |
---|
| 50 | 'not null' => TRUE, |
---|
| 51 | 'default' => '', |
---|
| 52 | 'description' => 'Id of the feed configuration.', |
---|
| 53 | ), |
---|
| 54 | 'feed_nid' => array( |
---|
| 55 | 'type' => 'int', |
---|
| 56 | 'not null' => TRUE, |
---|
| 57 | 'default' => 0, |
---|
| 58 | 'unsigned' => TRUE, |
---|
| 59 | 'description' => 'Node nid if this particular source is attached to a feed node.', |
---|
| 60 | ), |
---|
| 61 | 'config' => array( |
---|
| 62 | 'type' => 'text', |
---|
| 63 | 'not null' => FALSE, |
---|
| 64 | 'description' => 'Configuration of the source.', |
---|
| 65 | 'serialize' => TRUE, |
---|
| 66 | ), |
---|
| 67 | 'source' => array( |
---|
| 68 | 'type' => 'text', |
---|
| 69 | 'not null' => TRUE, |
---|
| 70 | 'description' => 'Main source resource identifier. E. g. a path or a URL.', |
---|
| 71 | ), |
---|
| 72 | 'batch' => array( |
---|
| 73 | 'type' => 'blob', |
---|
| 74 | 'size' => 'big', |
---|
| 75 | 'not null' => FALSE, |
---|
| 76 | 'description' => 'Cache for batching.', |
---|
| 77 | 'serialize' => TRUE, |
---|
| 78 | ), |
---|
| 79 | ), |
---|
| 80 | 'primary key' => array('id', 'feed_nid'), |
---|
| 81 | 'indexes' => array( |
---|
| 82 | 'id' => array('id'), |
---|
| 83 | 'feed_nid' => array('feed_nid'), |
---|
| 84 | 'id_source' => array('id', array('source', 128)), |
---|
| 85 | ), |
---|
| 86 | ); |
---|
| 87 | $schema['feeds_node_item'] = array( |
---|
| 88 | 'description' => 'Stores additional information about feed item nodes. Used by FeedsNodeProcessor.', |
---|
| 89 | 'fields' => array( |
---|
| 90 | 'nid' => array( |
---|
| 91 | 'type' => 'int', |
---|
| 92 | 'unsigned' => TRUE, |
---|
| 93 | 'not null' => TRUE, |
---|
| 94 | 'description' => "Primary Key: The feed item node's nid.", |
---|
| 95 | ), |
---|
| 96 | 'id' => array( |
---|
| 97 | 'type' => 'varchar', |
---|
| 98 | 'length' => 128, |
---|
| 99 | 'not null' => TRUE, |
---|
| 100 | 'default' => '', |
---|
| 101 | 'description' => 'The id of the fields object that is the producer of this item.', |
---|
| 102 | ), |
---|
| 103 | 'feed_nid' => array( |
---|
| 104 | 'type' => 'int', |
---|
| 105 | 'unsigned' => TRUE, |
---|
| 106 | 'not null' => TRUE, |
---|
| 107 | 'description' => "Node id of the owner feed, if available.", |
---|
| 108 | ), |
---|
| 109 | 'imported' => array( |
---|
| 110 | 'type' => 'int', |
---|
| 111 | 'not null' => TRUE, |
---|
| 112 | 'default' => 0, |
---|
| 113 | 'description' => 'Import date of the feed item, as a Unix timestamp.', |
---|
| 114 | ), |
---|
| 115 | 'url' => array( |
---|
| 116 | 'type' => 'text', |
---|
| 117 | 'not null' => TRUE, |
---|
| 118 | 'description' => 'Link to the feed item.', |
---|
| 119 | ), |
---|
| 120 | 'guid' => array( |
---|
| 121 | 'type' => 'text', |
---|
| 122 | 'not null' => TRUE, |
---|
| 123 | 'description' => 'Unique identifier for the feed item.' |
---|
| 124 | ), |
---|
| 125 | 'hash' => array( |
---|
| 126 | 'type' => 'varchar', |
---|
| 127 | 'length' => 32, // The length of an MD5 hash. |
---|
| 128 | 'not null' => TRUE, |
---|
| 129 | 'default' => '', |
---|
| 130 | 'description' => 'The hash of the source item.', |
---|
| 131 | ), |
---|
| 132 | ), |
---|
| 133 | 'primary key' => array('nid'), |
---|
| 134 | 'indexes' => array( |
---|
| 135 | 'id' => array('id'), |
---|
| 136 | 'feed_nid' => array('feed_nid'), |
---|
| 137 | 'imported' => array('imported'), |
---|
| 138 | 'url' => array(array('url', 255)), |
---|
| 139 | 'guid' => array(array('guid', 255)), |
---|
| 140 | ), |
---|
| 141 | ); |
---|
| 142 | $schema['feeds_term_item'] = array( |
---|
| 143 | 'description' => 'Tracks imported terms.', |
---|
| 144 | 'fields' => array( |
---|
| 145 | 'tid' => array( |
---|
| 146 | 'type' => 'int', |
---|
| 147 | 'unsigned' => TRUE, |
---|
| 148 | 'not null' => TRUE, |
---|
| 149 | 'default' => 0, |
---|
| 150 | 'description' => 'Imported term id.', |
---|
| 151 | ), |
---|
| 152 | 'id' => array( |
---|
| 153 | 'type' => 'varchar', |
---|
| 154 | 'length' => 128, |
---|
| 155 | 'not null' => TRUE, |
---|
| 156 | 'default' => '', |
---|
| 157 | 'description' => 'The id of the fields object that is the creator of this item.', |
---|
| 158 | ), |
---|
| 159 | 'feed_nid' => array( |
---|
| 160 | 'type' => 'int', |
---|
| 161 | 'unsigned' => TRUE, |
---|
| 162 | 'not null' => TRUE, |
---|
| 163 | 'description' => "Node id of the owner feed, if available.", |
---|
| 164 | ), |
---|
| 165 | 'imported' => array( |
---|
| 166 | 'type' => 'int', |
---|
| 167 | 'not null' => TRUE, |
---|
| 168 | 'default' => 0, |
---|
| 169 | 'description' => 'Import date of the feed item, as a Unix timestamp.', |
---|
| 170 | ), |
---|
| 171 | 'url' => array( |
---|
| 172 | 'type' => 'text', |
---|
| 173 | 'not null' => TRUE, |
---|
| 174 | 'description' => 'Link to the feed item.', |
---|
| 175 | ), |
---|
| 176 | 'guid' => array( |
---|
| 177 | 'type' => 'text', |
---|
| 178 | 'not null' => TRUE, |
---|
| 179 | 'description' => 'Unique identifier for the feed item.', |
---|
| 180 | ), |
---|
| 181 | ), |
---|
| 182 | 'primary key' => array('tid'), |
---|
| 183 | 'indexes' => array( |
---|
| 184 | 'id' => array('id'), |
---|
| 185 | 'feed_nid' => array('feed_nid'), |
---|
| 186 | 'imported' => array('imported'), |
---|
| 187 | 'url' => array(array('url', 255)), |
---|
| 188 | 'guid' => array(array('guid', 255)), |
---|
| 189 | ), |
---|
| 190 | ); |
---|
| 191 | $schema['feeds_push_subscriptions'] = array( |
---|
| 192 | 'description' => 'PubSubHubbub subscriptions.', |
---|
| 193 | 'fields' => array( |
---|
| 194 | 'domain' => array( |
---|
| 195 | 'type' => 'varchar', |
---|
| 196 | 'length' => 128, |
---|
| 197 | 'not null' => TRUE, |
---|
| 198 | 'default' => '', |
---|
| 199 | 'description' => 'Domain of the subscriber. Corresponds to an importer id.', |
---|
| 200 | ), |
---|
| 201 | 'subscriber_id' => array( |
---|
| 202 | 'type' => 'int', |
---|
| 203 | 'not null' => TRUE, |
---|
| 204 | 'default' => 0, |
---|
| 205 | 'unsigned' => TRUE, |
---|
| 206 | 'description' => 'ID of the subscriber. Corresponds to a feed nid.', |
---|
| 207 | ), |
---|
| 208 | 'timestamp' => array( |
---|
| 209 | 'type' => 'int', |
---|
| 210 | 'unsigned' => FALSE, |
---|
| 211 | 'default' => 0, |
---|
| 212 | 'not null' => TRUE, |
---|
| 213 | 'description' => 'Created timestamp.', |
---|
| 214 | ), |
---|
| 215 | 'hub' => array( |
---|
| 216 | 'type' => 'text', |
---|
| 217 | 'not null' => TRUE, |
---|
| 218 | 'description' => 'The URL of the hub endpoint of this subscription.', |
---|
| 219 | ), |
---|
| 220 | 'topic' => array( |
---|
| 221 | 'type' => 'text', |
---|
| 222 | 'not null' => TRUE, |
---|
| 223 | 'description' => 'The topic URL (feed URL) of this subscription.', |
---|
| 224 | ), |
---|
| 225 | 'secret' => array( |
---|
| 226 | 'type' => 'varchar', |
---|
| 227 | 'length' => 128, |
---|
| 228 | 'not null' => TRUE, |
---|
| 229 | 'default' => '', |
---|
| 230 | 'description' => 'Shared secret for message authentication.', |
---|
| 231 | ), |
---|
| 232 | 'status' => array( |
---|
| 233 | 'type' => 'varchar', |
---|
| 234 | 'length' => 64, |
---|
| 235 | 'not null' => TRUE, |
---|
| 236 | 'default' => '', |
---|
| 237 | 'description' => 'Status of subscription.', |
---|
| 238 | ), |
---|
| 239 | 'post_fields' => array( |
---|
| 240 | 'type' => 'text', |
---|
| 241 | 'not null' => FALSE, |
---|
| 242 | 'description' => 'Fields posted.', |
---|
| 243 | 'serialize' => TRUE, |
---|
| 244 | ), |
---|
| 245 | ), |
---|
| 246 | 'primary key' => array('domain', 'subscriber_id'), |
---|
| 247 | 'indexes' => array( |
---|
| 248 | 'timestamp' => array('timestamp'), |
---|
| 249 | ), |
---|
| 250 | ); |
---|
| 251 | return $schema; |
---|
| 252 | } |
---|
| 253 | |
---|
| 254 | /** |
---|
| 255 | * Implementation of hook_install(). |
---|
| 256 | */ |
---|
| 257 | function feeds_install() { |
---|
| 258 | // Create tables. |
---|
| 259 | drupal_install_schema('feeds'); |
---|
| 260 | } |
---|
| 261 | |
---|
| 262 | /** |
---|
| 263 | * Implementation of hook_uninstall(). |
---|
| 264 | */ |
---|
| 265 | function feeds_uninstall() { |
---|
| 266 | // Remove tables. |
---|
| 267 | drupal_uninstall_schema('feeds'); |
---|
| 268 | } |
---|
| 269 | |
---|
| 270 | /** |
---|
| 271 | * Remove class field on feeds_config. |
---|
| 272 | */ |
---|
| 273 | function feeds_update_6001() { |
---|
| 274 | $ret = array(); |
---|
| 275 | db_drop_field($ret, 'feeds_config', 'class'); |
---|
| 276 | return $ret; |
---|
| 277 | } |
---|
| 278 | |
---|
| 279 | /** |
---|
| 280 | * Rename table. |
---|
| 281 | */ |
---|
| 282 | function feeds_update_6002() { |
---|
| 283 | $ret = array(); |
---|
| 284 | db_rename_table($ret, 'feeds_config', 'feeds_importer'); |
---|
| 285 | return $ret; |
---|
| 286 | } |
---|
| 287 | |
---|
| 288 | /** |
---|
| 289 | * Add primary keys to feeds_importer and feeds_source. |
---|
| 290 | */ |
---|
| 291 | function feeds_update_6003() { |
---|
| 292 | $ret = array(); |
---|
| 293 | db_drop_index($ret, 'feeds_importer', 'id'); |
---|
| 294 | db_add_primary_key($ret, 'feeds_importer', array('id')); |
---|
| 295 | db_add_primary_key($ret, 'feeds_source', array('id', 'feed_nid')); |
---|
| 296 | return $ret; |
---|
| 297 | } |
---|
| 298 | |
---|
| 299 | /** |
---|
| 300 | * Add source field to feeds_source, make fields part of PKs not null. |
---|
| 301 | */ |
---|
| 302 | function feeds_update_6004() { |
---|
| 303 | $ret = array(); |
---|
| 304 | |
---|
| 305 | $spec = array( |
---|
| 306 | 'type' => 'text', |
---|
| 307 | 'not null' => TRUE, |
---|
| 308 | 'description' => t('Main source resource identifier. E. g. a path or a URL.'), |
---|
| 309 | ); |
---|
| 310 | db_add_field($ret, 'feeds_source', 'source', $spec); |
---|
| 311 | db_add_index($ret, 'feeds_source', 'id_source', array('id', array('source', 255))); |
---|
| 312 | |
---|
| 313 | // Make feed_nid not null, default 0. It is part of the primary key. |
---|
| 314 | $spec = array( |
---|
| 315 | 'type' => 'int', |
---|
| 316 | 'not null' => TRUE, |
---|
| 317 | 'default' => 0, |
---|
| 318 | 'unsigned' => TRUE, |
---|
| 319 | 'description' => 'Node nid if this particular source is attached to a feed node.', |
---|
| 320 | ); |
---|
| 321 | db_change_field($ret, 'feeds_schedule', 'feed_nid', 'feed_nid', $spec); |
---|
| 322 | |
---|
| 323 | |
---|
| 324 | // Same thing for feeds_source table. |
---|
| 325 | $spec = array( |
---|
| 326 | 'type' => 'int', |
---|
| 327 | 'not null' => TRUE, |
---|
| 328 | 'default' => 0, |
---|
| 329 | 'unsigned' => TRUE, |
---|
| 330 | 'description' => 'Node nid if this particular source is attached to a feed node.', |
---|
| 331 | ); |
---|
| 332 | db_change_field($ret, 'feeds_source', 'feed_nid', 'feed_nid', $spec); |
---|
| 333 | |
---|
| 334 | return $ret; |
---|
| 335 | } |
---|
| 336 | |
---|
| 337 | /** |
---|
| 338 | * Add callback column to feeds_schedule. |
---|
| 339 | */ |
---|
| 340 | function feeds_update_6005() { |
---|
| 341 | $ret = array(); |
---|
| 342 | |
---|
| 343 | // Add a callback column and an index. |
---|
| 344 | $spec = array( |
---|
| 345 | 'type' => 'varchar', |
---|
| 346 | 'length' => 128, |
---|
| 347 | 'not null' => TRUE, |
---|
| 348 | 'default' => '', |
---|
| 349 | 'description' => 'Callback to be invoked.', |
---|
| 350 | ); |
---|
| 351 | db_add_field($ret, 'feeds_schedule', 'callback', $spec); |
---|
| 352 | |
---|
| 353 | db_add_index($ret, 'feeds_schedule', 'id_callback', array('id', 'callback')); |
---|
| 354 | |
---|
| 355 | return $ret; |
---|
| 356 | } |
---|
| 357 | |
---|
| 358 | /** |
---|
| 359 | * Remove primary key from feeds_schedule and replace it by an index. |
---|
| 360 | */ |
---|
| 361 | function feeds_update_6006() { |
---|
| 362 | $ret = array(); |
---|
| 363 | |
---|
| 364 | db_drop_primary_key($ret, 'feeds_schedule'); |
---|
| 365 | db_add_index($ret, 'feeds_schedule', 'feed_nid', array('feed_nid')); |
---|
| 366 | |
---|
| 367 | return $ret; |
---|
| 368 | } |
---|
| 369 | |
---|
| 370 | /** |
---|
| 371 | * Add hash column to feeds_node_item. |
---|
| 372 | */ |
---|
| 373 | function feeds_update_6007() { |
---|
| 374 | $ret = array(); |
---|
| 375 | |
---|
| 376 | $spec = array( |
---|
| 377 | 'type' => 'varchar', |
---|
| 378 | 'length' => 32, |
---|
| 379 | 'not null' => TRUE, |
---|
| 380 | 'default' => '', |
---|
| 381 | 'description' => t('The hash of the item.'), |
---|
| 382 | ); |
---|
| 383 | db_add_field($ret, 'feeds_node_item', 'hash', $spec); |
---|
| 384 | |
---|
| 385 | return $ret; |
---|
| 386 | } |
---|
| 387 | |
---|
| 388 | /** |
---|
| 389 | * Add batch field to feeds_source table, adjust feeds_schedule table. |
---|
| 390 | */ |
---|
| 391 | function feeds_update_6008() { |
---|
| 392 | $ret = array(); |
---|
| 393 | |
---|
| 394 | $spec = array( |
---|
| 395 | 'type' => 'text', |
---|
| 396 | 'size' => 'big', |
---|
| 397 | 'not null' => FALSE, |
---|
| 398 | 'description' => t('Cache for batching.'), |
---|
| 399 | 'serialize' => TRUE, |
---|
| 400 | ); |
---|
| 401 | db_add_field($ret, 'feeds_source', 'batch', $spec); |
---|
| 402 | |
---|
| 403 | // Make scheduled flag a timestamp. |
---|
| 404 | $spec = array( |
---|
| 405 | 'type' => 'int', |
---|
| 406 | 'size' => 'normal', |
---|
| 407 | 'unsigned' => TRUE, |
---|
| 408 | 'default' => 0, |
---|
| 409 | 'not null' => TRUE, |
---|
| 410 | 'description' => 'Timestamp when a job was scheduled. 0 if a job is currently not scheduled.', |
---|
| 411 | ); |
---|
| 412 | db_change_field($ret, 'feeds_schedule', 'scheduled', 'scheduled', $spec); |
---|
| 413 | |
---|
| 414 | // Rename last_scheduled_time to last_executed_time, fix unsigned property. |
---|
| 415 | $spec = array( |
---|
| 416 | 'type' => 'int', |
---|
| 417 | 'size' => 'normal', |
---|
| 418 | 'unsigned' => TRUE, |
---|
| 419 | 'default' => 0, |
---|
| 420 | 'not null' => TRUE, |
---|
| 421 | 'description' => 'Timestamp when a job was last executed.', |
---|
| 422 | ); |
---|
| 423 | db_change_field($ret, 'feeds_schedule', 'last_scheduled_time', 'last_executed_time', $spec); |
---|
| 424 | |
---|
| 425 | return $ret; |
---|
| 426 | } |
---|
| 427 | |
---|
| 428 | /** |
---|
| 429 | * Add feeds_push_subscriptions tables. |
---|
| 430 | */ |
---|
| 431 | function feeds_update_6009() { |
---|
| 432 | $ret = array(); |
---|
| 433 | $table = array( |
---|
| 434 | 'description' => 'PubSubHubbub subscriptions.', |
---|
| 435 | 'fields' => array( |
---|
| 436 | 'domain' => array( |
---|
| 437 | 'type' => 'varchar', |
---|
| 438 | 'length' => 128, |
---|
| 439 | 'not null' => TRUE, |
---|
| 440 | 'default' => '', |
---|
| 441 | 'description' => 'Domain of the subscriber. Corresponds to an importer id.', |
---|
| 442 | ), |
---|
| 443 | 'subscriber_id' => array( |
---|
| 444 | 'type' => 'int', |
---|
| 445 | 'not null' => TRUE, |
---|
| 446 | 'default' => 0, |
---|
| 447 | 'unsigned' => TRUE, |
---|
| 448 | 'description' => 'ID of the subscriber. Corresponds to a feed nid.', |
---|
| 449 | ), |
---|
| 450 | 'timestamp' => array( |
---|
| 451 | 'type' => 'int', |
---|
| 452 | 'unsigned' => FALSE, |
---|
| 453 | 'default' => 0, |
---|
| 454 | 'not null' => TRUE, |
---|
| 455 | 'description' => 'Created timestamp.', |
---|
| 456 | ), |
---|
| 457 | 'hub' => array( |
---|
| 458 | 'type' => 'text', |
---|
| 459 | 'not null' => TRUE, |
---|
| 460 | 'description' => t('The URL of the hub endpoint of this subscription.'), |
---|
| 461 | ), |
---|
| 462 | 'topic' => array( |
---|
| 463 | 'type' => 'text', |
---|
| 464 | 'not null' => TRUE, |
---|
| 465 | 'description' => t('The topic URL (feed URL) of this subscription.'), |
---|
| 466 | ), |
---|
| 467 | 'secret' => array( |
---|
| 468 | 'type' => 'varchar', |
---|
| 469 | 'length' => 128, |
---|
| 470 | 'not null' => TRUE, |
---|
| 471 | 'default' => '', |
---|
| 472 | 'description' => 'Shared secret for message authentication.', |
---|
| 473 | ), |
---|
| 474 | 'status' => array( |
---|
| 475 | 'type' => 'varchar', |
---|
| 476 | 'length' => 64, |
---|
| 477 | 'not null' => TRUE, |
---|
| 478 | 'default' => '', |
---|
| 479 | 'description' => 'Status of subscription.', |
---|
| 480 | ), |
---|
| 481 | 'post_fields' => array( |
---|
| 482 | 'type' => 'text', |
---|
| 483 | 'not null' => FALSE, |
---|
| 484 | 'description' => 'Fields posted.', |
---|
| 485 | 'serialize' => TRUE, |
---|
| 486 | ), |
---|
| 487 | ), |
---|
| 488 | 'primary key' => array('domain', 'subscriber_id'), |
---|
| 489 | 'indexes' => array( |
---|
| 490 | 'timestamp' => array('timestamp'), |
---|
| 491 | ), |
---|
| 492 | ); |
---|
| 493 | db_create_table($ret, 'feeds_push_subscriptions', $table); |
---|
| 494 | return $ret; |
---|
| 495 | } |
---|
| 496 | |
---|
| 497 | /** |
---|
| 498 | * Show a message about Feeds News, Feeds Import and Feeds fast news features. |
---|
| 499 | */ |
---|
| 500 | function feeds_update_6010() { |
---|
| 501 | drupal_set_message(t('You may install Feeds News and Feeds Import as replacement for Feeds Defaults module.')); |
---|
| 502 | |
---|
| 503 | if (module_exists('features')) { |
---|
| 504 | drupal_set_message(t('<strong>Review enabled state of importer configurations on admin/build/feeds and features on admin/build/features.</strong>')); |
---|
| 505 | } |
---|
| 506 | else { |
---|
| 507 | drupal_set_message(t('<strong>Review enabled state of importer configurations on admin/build/feeds and Feeds modules on admin/build/modules.</strong>')); |
---|
| 508 | } |
---|
| 509 | return array(); |
---|
| 510 | } |
---|
| 511 | |
---|
| 512 | /** |
---|
| 513 | * Add imported flag for terms. |
---|
| 514 | */ |
---|
| 515 | function feeds_update_6011() { |
---|
| 516 | $ret = array(); |
---|
| 517 | $schema = array( |
---|
| 518 | 'description' => 'Tracks imported terms.', |
---|
| 519 | 'fields' => array( |
---|
| 520 | 'tid' => array( |
---|
| 521 | 'type' => 'int', |
---|
| 522 | 'unsigned' => TRUE, |
---|
| 523 | 'not null' => TRUE, |
---|
| 524 | 'default' => 0, |
---|
| 525 | 'description' => 'Imported term id.', |
---|
| 526 | ), |
---|
| 527 | 'id' => array( |
---|
| 528 | 'type' => 'varchar', |
---|
| 529 | 'length' => 128, |
---|
| 530 | 'not null' => TRUE, |
---|
| 531 | 'default' => '', |
---|
| 532 | 'description' => 'The id of the fields object that is the creator of this item.', |
---|
| 533 | ), |
---|
| 534 | 'feed_nid' => array( |
---|
| 535 | 'type' => 'int', |
---|
| 536 | 'unsigned' => TRUE, |
---|
| 537 | 'not null' => TRUE, |
---|
| 538 | 'description' => t("Node id of the owner feed, if available."), |
---|
| 539 | ), |
---|
| 540 | ), |
---|
| 541 | 'primary key' => array('tid'), |
---|
| 542 | 'indexes' => array( |
---|
| 543 | 'id_feed_nid' => array('id', 'feed_nid'), |
---|
| 544 | 'feed_nid' => array('feed_nid'), |
---|
| 545 | ), |
---|
| 546 | ); |
---|
| 547 | db_create_table($ret, 'feeds_term_item', $schema); |
---|
| 548 | return $ret; |
---|
| 549 | } |
---|
| 550 | |
---|
| 551 | /** |
---|
| 552 | * Drop schedule table install Job Scheduler module. |
---|
| 553 | */ |
---|
| 554 | function feeds_update_6012() { |
---|
| 555 | $ret = array(); |
---|
| 556 | // Only attempt installation if module is present, otherwise we would leave |
---|
| 557 | // the system table in a limbo. |
---|
| 558 | $modules = module_rebuild_cache(); |
---|
| 559 | if (isset($modules['job_scheduler'])) { |
---|
| 560 | if (!$modules['job_scheduler']->status) { |
---|
| 561 | drupal_install_modules(array('job_scheduler')); |
---|
| 562 | drupal_set_message(t('Installed Job Scheduler module.')); |
---|
| 563 | } |
---|
| 564 | } |
---|
| 565 | else { |
---|
| 566 | drupal_set_message(t('NOTE: Please install new dependency of Feeds: <a href="@job-scheduler-link">Job scheduler module</a>.', array('@job-scheduler-link' => url('http://drupal.org/project/job_scheduler'))), 'warning'); |
---|
| 567 | } |
---|
| 568 | db_drop_table($ret, 'feeds_schedule'); |
---|
| 569 | return $ret; |
---|
| 570 | } |
---|
| 571 | |
---|
| 572 | /** |
---|
| 573 | * Reschedule all tasks. |
---|
| 574 | */ |
---|
| 575 | function feeds_update_6013() { |
---|
| 576 | // This was originally part of 6012 upgrade, but failed due to usage of |
---|
| 577 | // API functions residing in feeds.module. Make sure it runs again for all |
---|
| 578 | // users of Feeds. |
---|
| 579 | variable_set('feeds_reschedule', TRUE); |
---|
| 580 | return array(); |
---|
| 581 | } |
---|
| 582 | |
---|
| 583 | /** |
---|
| 584 | * Update feeds_term_item to match feeds_node_item. |
---|
| 585 | */ |
---|
| 586 | function feeds_update_6014() { |
---|
| 587 | $ret = array(); |
---|
| 588 | |
---|
| 589 | // Define new fields. |
---|
| 590 | $fields = array( |
---|
| 591 | 'imported' => array( |
---|
| 592 | 'type' => 'int', |
---|
| 593 | 'not null' => TRUE, |
---|
| 594 | 'default' => 0, |
---|
| 595 | 'description' => t('Import date of the feed item, as a Unix timestamp.'), |
---|
| 596 | ), |
---|
| 597 | 'url' => array( |
---|
| 598 | 'type' => 'text', |
---|
| 599 | 'not null' => TRUE, |
---|
| 600 | 'description' => t('Link to the feed item.'), |
---|
| 601 | ), |
---|
| 602 | 'guid' => array( |
---|
| 603 | 'type' => 'text', |
---|
| 604 | 'not null' => TRUE, |
---|
| 605 | 'description' => t('Unique identifier for the feed item.'), |
---|
| 606 | ), |
---|
| 607 | ); |
---|
| 608 | |
---|
| 609 | // Add new fields. |
---|
| 610 | foreach ($fields as $field => $data) { |
---|
| 611 | db_add_field($ret, 'feeds_term_item', $field, $data); |
---|
| 612 | } |
---|
| 613 | |
---|
| 614 | // Add new indexes, drop id_feed_nid. |
---|
| 615 | db_drop_index($ret, 'feeds_term_item', 'id_feed_nid'); |
---|
| 616 | |
---|
| 617 | db_add_index($ret, 'feeds_term_item', 'id', array('id')); |
---|
| 618 | db_add_index($ret, 'feeds_term_item', 'imported', array('imported')); |
---|
| 619 | db_add_index($ret, 'feeds_term_item', 'url', array(array('url', 255))); |
---|
| 620 | db_add_index($ret, 'feeds_term_item', 'guid', array(array('guid', 255))); |
---|
| 621 | |
---|
| 622 | return $ret; |
---|
| 623 | } |
---|
| 624 | |
---|
| 625 | /** |
---|
| 626 | * Change batch field from text to blob. |
---|
| 627 | */ |
---|
| 628 | function feeds_update_6015() { |
---|
| 629 | $ret = array(); |
---|
| 630 | |
---|
| 631 | $spec = array( |
---|
| 632 | 'type' => 'blob', |
---|
| 633 | 'size' => 'big', |
---|
| 634 | 'not null' => FALSE, |
---|
| 635 | 'description' => t('Cache for batching.'), |
---|
| 636 | 'serialize' => TRUE, |
---|
| 637 | ); |
---|
| 638 | |
---|
| 639 | db_change_field($ret, 'feeds_source', 'batch', 'batch', $spec); |
---|
| 640 | |
---|
| 641 | return $ret; |
---|
| 642 | } |
---|