123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563 |
- <?php
- /**
- * @file
- * Schema definitions install/update/uninstall hooks.
- */
- /**
- * Implements hook_schema().
- */
- function feeds_schema() {
- $schema = array();
- $schema['feeds_importer'] = array(
- 'description' => 'Configuration of feeds objects.',
- 'export' => array(
- 'key' => 'id',
- 'identifier' => 'feeds_importer',
- 'default hook' => 'feeds_importer_default', // Function hook name.
- 'api' => array(
- 'owner' => 'feeds',
- 'api' => 'feeds_importer_default', // Base name for api include files.
- 'minimum_version' => 1,
- 'current_version' => 1,
- ),
- ),
- 'fields' => array(
- 'id' => array(
- 'type' => 'varchar',
- 'length' => 128,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'Id of the fields object.',
- ),
- 'config' => array(
- 'type' => 'blob',
- 'size' => 'big',
- 'not null' => FALSE,
- 'description' => 'Configuration of the feeds object.',
- 'serialize' => TRUE,
- ),
- ),
- 'primary key' => array('id'),
- );
- $schema['feeds_source'] = array(
- 'description' => 'Source definitions for feeds.',
- 'fields' => array(
- 'id' => array(
- 'type' => 'varchar',
- 'length' => 128,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'Id of the feed configuration.',
- ),
- 'feed_nid' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- 'unsigned' => TRUE,
- 'description' => 'Node nid if this particular source is attached to a feed node.',
- ),
- 'config' => array(
- 'type' => 'blob',
- 'size' => 'big',
- 'not null' => FALSE,
- 'description' => 'Configuration of the source.',
- 'serialize' => TRUE,
- ),
- 'source' => array(
- 'type' => 'text',
- 'not null' => TRUE,
- 'description' => 'Main source resource identifier. E. g. a path or a URL.',
- ),
- 'state' => array(
- 'type' => 'blob',
- 'size' => 'big',
- 'not null' => FALSE,
- 'description' => 'State of import or clearing batches.',
- 'serialize' => TRUE,
- ),
- 'fetcher_result' => array(
- 'type' => 'blob',
- 'size' => 'big',
- 'not null' => FALSE,
- 'description' => 'Cache for fetcher result.',
- 'serialize' => TRUE,
- ),
- 'imported' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- 'unsigned' => TRUE,
- 'description' => 'Timestamp when this source was imported last.',
- ),
- ),
- 'primary key' => array('id', 'feed_nid'),
- 'indexes' => array(
- 'id' => array('id'),
- 'feed_nid' => array('feed_nid'),
- 'id_source' => array('id', array('source', 128)),
- ),
- );
- $schema['feeds_item'] = 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)),
- 'global_lookup_url' => array('entity_type', array('url', 128)),
- 'global_lookup_guid' => array('entity_type', array('guid', 128)),
- 'imported' => array('imported'),
- ),
- );
- $schema['feeds_push_subscriptions'] = array(
- 'description' => 'PubSubHubbub subscriptions.',
- 'fields' => array(
- 'domain' => array(
- 'type' => 'varchar',
- 'length' => 128,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'Domain of the subscriber. Corresponds to an importer id.',
- ),
- 'subscriber_id' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- 'unsigned' => TRUE,
- 'description' => 'ID of the subscriber. Corresponds to a feed nid.',
- ),
- 'timestamp' => array(
- 'type' => 'int',
- 'unsigned' => FALSE,
- 'default' => 0,
- 'not null' => TRUE,
- 'description' => 'Created timestamp.',
- ),
- 'hub' => array(
- 'type' => 'text',
- 'not null' => TRUE,
- 'description' => 'The URL of the hub endpoint of this subscription.',
- ),
- 'topic' => array(
- 'type' => 'text',
- 'not null' => TRUE,
- 'description' => 'The topic URL (feed URL) of this subscription.',
- ),
- 'secret' => array(
- 'type' => 'varchar',
- 'length' => 128,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'Shared secret for message authentication.',
- ),
- 'status' => array(
- 'type' => 'varchar',
- 'length' => 64,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'Status of subscription.',
- ),
- 'post_fields' => array(
- 'type' => 'text',
- 'not null' => FALSE,
- 'description' => 'Fields posted.',
- 'serialize' => TRUE,
- ),
- ),
- 'primary key' => array('domain', 'subscriber_id'),
- 'indexes' => array(
- 'timestamp' => array('timestamp'),
- ),
- );
- $schema['feeds_log'] = array(
- 'description' => 'Table that contains logs of feeds events.',
- 'fields' => array(
- 'flid' => array(
- 'type' => 'serial',
- 'not null' => TRUE,
- 'description' => 'Primary Key: Unique feeds event ID.',
- ),
- 'id' => array(
- 'type' => 'varchar',
- 'length' => 128,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'The id of the importer that logged the event.',
- ),
- 'feed_nid' => array(
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'description' => 'Node id of the source, if available.',
- ),
- 'log_time' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- 'description' => 'Unix timestamp of when event occurred.',
- ),
- 'request_time' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- 'description' => 'Unix timestamp of the request when the event occurred.',
- ),
- 'type' => array(
- 'type' => 'varchar',
- 'length' => 64,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'Type of log message, for example "feeds_import"."',
- ),
- 'message' => array(
- 'type' => 'text',
- 'not null' => TRUE,
- 'size' => 'big',
- 'description' => 'Text of log message to be passed into the t() function.',
- ),
- 'variables' => array(
- 'type' => 'blob',
- 'not null' => TRUE,
- 'size' => 'big',
- 'description' => 'Serialized array of variables that match the message string and that is passed into the t() function.',
- ),
- 'severity' => array(
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'default' => 0,
- 'size' => 'tiny',
- 'description' => 'The severity level of the event; ranges from 0 (Emergency) to 7 (Debug)',
- ),
- ),
- 'primary key' => array('flid'),
- 'indexes' => array(
- 'id' => array('id'),
- 'id_feed_nid' => array('id', 'feed_nid'),
- 'request_time' => array('request_time'),
- 'log_time' => array('log_time'),
- 'type' => array('type'),
- ),
- );
- return $schema;
- }
- /**
- * Rename feeds_source.batch to feeds_source.state, add slot for caching fetcher
- * result.
- */
- function feeds_update_7100() {
- $spec = array(
- 'type' => 'text',
- 'size' => 'big',
- 'not null' => FALSE,
- 'description' => 'State of import or clearing batches.',
- 'serialize' => TRUE,
- );
- db_change_field('feeds_source', 'batch', 'state', $spec);
- $spec = array(
- 'type' => 'text',
- 'size' => 'big',
- 'not null' => FALSE,
- 'description' => 'Cache for fetcher result.',
- 'serialize' => TRUE,
- );
- db_add_field('feeds_source', 'fetcher_result', $spec);
- }
- /**
- * Add imported timestamp to feeds_source table.
- */
- function feeds_update_7201() {
- $spec = array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- 'unsigned' => TRUE,
- 'description' => 'Timestamp when this source was imported last.',
- );
- db_add_field('feeds_source', 'imported', $spec);
- }
- /**
- * Create a single feeds_item table tracking all imports.
- */
- 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');
- }
- /**
- * Add feeds_log table.
- */
- function feeds_update_7203() {
- $schema = array(
- 'description' => 'Table that contains logs of feeds events.',
- 'fields' => array(
- 'flid' => array(
- 'type' => 'serial',
- 'not null' => TRUE,
- 'description' => 'Primary Key: Unique feeds event ID.',
- ),
- 'id' => array(
- 'type' => 'varchar',
- 'length' => 128,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'The id of the importer that logged the event.',
- ),
- 'feed_nid' => array(
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'description' => 'Node id of the source, if available.',
- ),
- 'log_time' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- 'description' => 'Unix timestamp of when event occurred.',
- ),
- 'request_time' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- 'description' => 'Unix timestamp of the request when the event occurred.',
- ),
- 'type' => array(
- 'type' => 'varchar',
- 'length' => 64,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'Type of log message, for example "feeds_import"."',
- ),
- 'message' => array(
- 'type' => 'text',
- 'not null' => TRUE,
- 'size' => 'big',
- 'description' => 'Text of log message to be passed into the t() function.',
- ),
- 'variables' => array(
- 'type' => 'blob',
- 'not null' => TRUE,
- 'size' => 'big',
- 'description' => 'Serialized array of variables that match the message string and that is passed into the t() function.',
- ),
- 'severity' => array(
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'default' => 0,
- 'size' => 'tiny',
- 'description' => 'The severity level of the event; ranges from 0 (Emergency) to 7 (Debug)',
- ),
- ),
- 'primary key' => array('flid'),
- 'indexes' => array(
- 'id' => array('id'),
- 'id_feed_nid' => array('id', 'feed_nid'),
- 'request_time' => array('request_time'),
- 'log_time' => array('log_time'),
- 'type' => array('type'),
- ),
- );
- db_create_table('feeds_log', $schema);
- }
- /**
- * Add index for looking up by entity_type + url/ guid to feeds_item table.
- */
- function feeds_update_7204() {
- db_add_index('feeds_item', 'global_lookup_url', array('entity_type', array('url', 128)));
- db_add_index('feeds_item', 'global_lookup_guid', array('entity_type', array('guid', 128)));
- }
- /**
- * Shorten {feeds_item}.entity_type to 32 chars and shorten relevant indexes.
- */
- function feeds_update_7205() {
- db_drop_primary_key('feeds_item');
- db_drop_index('feeds_item', 'lookup_url');
- db_drop_index('feeds_item', 'lookup_guid');
- db_drop_index('feeds_item', 'global_lookup_url');
- db_drop_index('feeds_item', 'global_lookup_guid');
- db_change_field('feeds_item', 'entity_type', 'entity_type', array(
- 'type' => 'varchar',
- 'length' => 32,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'The entity type.',
- ));
- db_add_primary_key('feeds_item', array('entity_type', 'entity_id'));
- db_add_index('feeds_item', 'lookup_url', array('entity_type', 'id', 'feed_nid', array('url', 128)));
- db_add_index('feeds_item', 'lookup_guid', array('entity_type', 'id', 'feed_nid', array('guid', 128)));
- db_add_index('feeds_item', 'global_lookup_url', array('entity_type', array('url', 128)));
- db_add_index('feeds_item', 'global_lookup_guid', array('entity_type', array('guid', 128)));
- }
- /**
- * Change state and fetcher_result fields from text to blob.
- */
- function feeds_update_7206() {
- db_change_field('feeds_source', 'state', 'state', array(
- 'type' => 'blob',
- 'size' => 'big',
- 'not null' => FALSE,
- 'description' => 'State of import or clearing batches.',
- 'serialize' => TRUE,
- ));
- db_change_field('feeds_source', 'fetcher_result', 'fetcher_result', array(
- 'type' => 'blob',
- 'size' => 'big',
- 'not null' => FALSE,
- 'description' => 'Cache for fetcher result.',
- 'serialize' => TRUE,
- ));
- }
- /**
- * Change config fields from text to big blobs.
- */
- function feeds_update_7207() {
- db_change_field('feeds_importer', 'config', 'config', array(
- 'type' => 'blob',
- 'size' => 'big',
- 'not null' => FALSE,
- 'description' => 'Configuration of the feeds object.',
- 'serialize' => TRUE,
- ));
- db_change_field('feeds_source', 'config', 'config', array(
- 'type' => 'blob',
- 'size' => 'big',
- 'not null' => FALSE,
- 'description' => 'Configuration of the feeds object.',
- 'serialize' => TRUE,
- ));
- }
|