function feeds_update_7202 in Feeds 8.2
Same name and namespace in other branches
- 7.2 feeds.install \feeds_update_7202()
Create a single feeds_item table tracking all imports.
File
- ./
feeds.install, line 394 - Schema definitions install/update/uninstall hooks.
Code
function feeds_update_7202() {
$spec = array(
'description' => 'Tracks items such as nodes, terms, users.',
'fields' => array(
'entity_type' => array(
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
'description' => 'The entity type.',
),
'entity_id' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'The imported entity\'s serial id.',
),
'id' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
'description' => 'The id of the importer that created this item.',
),
'feed_nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'Node id of the source, if available.',
),
'imported' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'Import date of the feed item, as a Unix timestamp.',
),
'url' => array(
'type' => 'text',
'not null' => TRUE,
'description' => 'Link to the feed item.',
),
'guid' => array(
'type' => 'text',
'not null' => TRUE,
'description' => 'Unique identifier for the feed item.',
),
'hash' => array(
'type' => 'varchar',
'length' => 32,
// The length of an MD5 hash.
'not null' => TRUE,
'default' => '',
'description' => 'The hash of the source item.',
),
),
'primary key' => array(
'entity_type',
'entity_id',
),
'indexes' => array(
'id' => array(
'id',
),
'feed_nid' => array(
'feed_nid',
),
'lookup_url' => array(
'entity_type',
'id',
'feed_nid',
array(
'url',
128,
),
),
'lookup_guid' => array(
'entity_type',
'id',
'feed_nid',
array(
'guid',
128,
),
),
'imported' => array(
'imported',
),
),
);
db_create_table('feeds_item', $spec);
// Copy all existing values from old tables and drop them.
$insert = "INSERT INTO {feeds_item} (entity_type, entity_id, id, feed_nid, imported, url, guid, hash)";
db_query($insert . " SELECT 'node', nid, id, feed_nid, imported, url, guid, hash FROM {feeds_node_item}");
db_query($insert . " SELECT 'taxonomy_term', tid, id, feed_nid, 0, '', '', '' FROM {feeds_term_item}");
db_drop_table('feeds_node_item');
db_drop_table('feeds_term_item');
}