6 * Schema definitions install/update/uninstall hooks.
10 * Implements hook_schema().
12 function feeds_schema() {
15 $schema['feeds_importer'] = array(
16 'description' => 'Configuration of feeds objects.',
19 'identifier' => 'feeds_importer',
20 'default hook' => 'feeds_importer_default', // Function hook name.
23 'api' => 'feeds_importer_default', // Base name for api include files.
24 'minimum_version' => 1,
25 'current_version' => 1,
34 'description' => 'Id of the fields object.',
39 'description' => 'Configuration of the feeds object.',
43 'primary key' => array('id'),
45 $schema['feeds_source'] = array(
46 'description' => 'Source definitions for feeds.',
53 'description' => 'Id of the feed configuration.',
60 'description' => 'Node nid if this particular source is attached to a feed node.',
65 'description' => 'Configuration of the source.',
71 'description' => 'Main source resource identifier. E. g. a path or a URL.',
77 'description' => 'Cache for batching.',
78 'description' => 'State of import or clearing batches.',
81 'fetcher_result' => array(
85 'description' => 'Cache for fetcher result.',
89 'primary key' => array('id', 'feed_nid'),
92 'feed_nid' => array('feed_nid'),
93 'id_source' => array('id', array('source', 128)),
96 $schema['feeds_node_item'] = array(
97 'description' => 'Stores additional information about feed item nodes. Used by FeedsNodeProcessor.',
103 'description' => 'Primary Key: The feed item node\'s nid.',
110 'description' => 'The id of the fields object that is the producer of this item.',
116 'description' => 'Node id of the owner feed, if available.',
122 'description' => 'Import date of the feed item, as a Unix timestamp.',
127 'description' => 'Link to the feed item.',
132 'description' => 'Unique identifier for the feed item.'
136 'length' => 32, // The length of an MD5 hash.
139 'description' => 'The hash of the item.',
142 'primary key' => array('nid'),
145 'feed_nid' => array('feed_nid'),
146 'imported' => array('imported'),
147 'url' => array(array('url', 255)),
148 'guid' => array(array('guid', 255)),
151 $schema['feeds_term_item'] = array(
152 'description' => 'Tracks imported terms.',
159 'description' => 'Imported term id.',
166 'description' => 'The id of the fields object that is the creator of this item.',
172 'description' => 'Node id of the owner feed, if available.',
175 'primary key' => array('tid'),
177 'id_feed_nid' => array('id', 'feed_nid'),
178 'feed_nid' => array('feed_nid'),
181 $schema['feeds_push_subscriptions'] = array(
182 'description' => 'PubSubHubbub subscriptions.',
189 'description' => 'Domain of the subscriber. Corresponds to an importer id.',
191 'subscriber_id' => array(
196 'description' => 'ID of the subscriber. Corresponds to a feed nid.',
198 'timestamp' => array(
203 'description' => 'Created timestamp.',
208 'description' => 'The URL of the hub endpoint of this subscription.',
213 'description' => 'The topic URL (feed URL) of this subscription.',
220 'description' => 'Shared secret for message authentication.',
227 'description' => 'Status of subscription.',
229 'post_fields' => array(
232 'description' => 'Fields posted.',
236 'primary key' => array('domain', 'subscriber_id'),
238 'timestamp' => array('timestamp'),
245 * Remove class field on feeds_config.
247 function feeds_update_6001() {
249 db_drop_field($ret, 'feeds_config', 'class');
256 function feeds_update_6002() {
258 db_rename_table($ret, 'feeds_config', 'feeds_importer');
263 * Add primary keys to feeds_importer and feeds_source.
265 function feeds_update_6003() {
267 db_drop_index($ret, 'feeds_importer', 'id');
268 db_add_primary_key($ret, 'feeds_importer', array('id'));
269 db_add_primary_key($ret, 'feeds_source', array('id', 'feed_nid'));
274 * Add source field to feeds_source, make fields part of PKs not null.
276 function feeds_update_6004() {
282 'description' => 'Main source resource identifier. E. g. a path or a URL.',
284 db_add_field($ret, 'feeds_source', 'source', $spec);
285 db_add_index($ret, 'feeds_source', 'id_source', array('id', array('source', 255)));
287 // Make feed_nid not null, default 0. It is part of the primary key.
293 'description' => 'Node nid if this particular source is attached to a feed node.',
295 db_change_field($ret, 'feeds_schedule', 'feed_nid', 'feed_nid', $spec);
298 // Same thing for feeds_source table.
304 'description' => 'Node nid if this particular source is attached to a feed node.',
306 db_change_field($ret, 'feeds_source', 'feed_nid', 'feed_nid', $spec);
312 * Add callback column to feeds_schedule.
314 function feeds_update_6005() {
317 // Add a callback column and an index.
323 'description' => 'Callback to be invoked.',
325 db_add_field($ret, 'feeds_schedule', 'callback', $spec);
327 db_add_index($ret, 'feeds_schedule', 'id_callback', array('id', 'callback'));
333 * Remove primary key from feeds_schedule and replace it by an index.
335 function feeds_update_6006() {
338 db_drop_primary_key($ret, 'feeds_schedule');
339 db_add_index($ret, 'feeds_schedule', 'feed_nid', array('feed_nid'));
345 * Add hash column to feeds_node_item.
347 function feeds_update_6007() {
355 'description' => 'The hash of the item.',
357 db_add_field($ret, 'feeds_node_item', 'hash', $spec);
363 * Add batch field to feeds_source table, adjust feeds_schedule table.
365 function feeds_update_6008() {
372 'description' => 'Cache for batching.',
375 db_add_field($ret, 'feeds_source', 'batch', $spec);
377 // Make scheduled flag a timestamp.
384 'description' => 'Timestamp when a job was scheduled. 0 if a job is currently not scheduled.',
386 db_change_field($ret, 'feeds_schedule', 'scheduled', 'scheduled', $spec);
388 // Rename last_scheduled_time to last_executed_time, fix unsigned property.
395 'description' => 'Timestamp when a job was last executed.',
397 db_change_field($ret, 'feeds_schedule', 'last_scheduled_time', 'last_executed_time', $spec);
403 * Add feeds_push_subscriptions tables.
405 function feeds_update_6009() {
408 'description' => 'PubSubHubbub subscriptions.',
415 'description' => 'Domain of the subscriber. Corresponds to an importer id.',
417 'subscriber_id' => array(
422 'description' => 'ID of the subscriber. Corresponds to a feed nid.',
424 'timestamp' => array(
429 'description' => 'Created timestamp.',
434 'description' => 'The URL of the hub endpoint of this subscription.',
439 'description' => 'The topic URL (feed URL) of this subscription.',
446 'description' => 'Shared secret for message authentication.',
453 'description' => 'Status of subscription.',
455 'post_fields' => array(
458 'description' => 'Fields posted.',
462 'primary key' => array('domain', 'subscriber_id'),
464 'timestamp' => array('timestamp'),
467 db_create_table($ret, 'feeds_push_subscriptions', $table);
472 * Enable all Feeds News, Feeds Import and Feeds fast news features.
474 function feeds_update_6010() {
475 drupal_install_modules(array('feeds_news', 'feeds_import'));
476 if (module_exists('data')) {
477 drupal_install_modules(array('feeds_fast_news'));
478 drupal_set_message(t('Installed Feeds News, Feeds Fast News and Feeds Import as replacement for Feeds Defaults module. If you were not using Feeds Defaults then you can safely disable Feeds News and Feeds Import.'));
481 drupal_set_message(t('Installed Feeds News and Feeds Import as replacement for Feeds Defaults module. If you were not using Feeds Defaults then you can safely disable Feeds News and Feeds Import.'));
483 if (module_exists('features')) {
484 drupal_set_message(t('<strong>Review enabled state of importer configurations on admin/structure/feeds and features on admin/build/features.</strong>'));
487 drupal_set_message(t('<strong>Review enabled state of importer configurations on admin/structure/feeds and Feeds modules on admin/build/modules.</strong>'));
493 * Add imported flag for terms.
495 function feeds_update_6011() {
498 'description' => 'Tracks imported terms.',
505 'description' => 'Imported term id.',
512 'description' => 'The id of the fields object that is the creator of this item.',
518 'description' => "Node id of the owner feed, if available.",
521 'primary key' => array('tid'),
523 'id_feed_nid' => array('id', 'feed_nid'),
524 'feed_nid' => array('feed_nid'),
527 db_create_table($ret, 'feeds_term_item', $schema);
532 * Drop schedule table and reschedule all tasks, install Job Scheduler module.
534 function feeds_update_6012() {
536 // Only attempt installation if module is present, otherwise we would leave
537 // the system table in a limbo.
538 $modules = module_rebuild_cache();
539 if (isset($modules['job_scheduler'])) {
540 if (!$modules['job_scheduler']->status
) {
541 drupal_install_modules(array('job_scheduler'));
542 drupal_set_message(t('Installed Job Scheduler module.'));
546 drupal_set_message(t('NOTE: Please install new dependency of Feeds: !job_scheduler module.', array('!job_scheduler' => l(t('Job Scheduler'), 'http://drupal.org/project/job_scheduler'))), 'warning');
548 db_drop_table($ret, 'feeds_schedule');
549 feeds_reschedule(TRUE
);
554 * Rename feeds_source.batch to feeds_source.state, add slot for caching fetcher
557 function feeds_update_7100(&$sandbox) {
562 'description' => 'State of import or clearing batches.',
565 db_change_field('feeds_source', 'batch', 'state', $spec);
571 'description' => 'Cache for fetcher result.',
574 db_add_field('feeds_source', 'fetcher_result', $spec);