function apachesolr_attachments_update_7003 in Apache Solr Attachments 7
Same name and namespace in other branches
- 6.3 apachesolr_attachments.install \apachesolr_attachments_update_7003()
Change DB tables to support multiple entity indexing.
File
- ./
apachesolr_attachments.install, line 172 - Install, update and uninstall functions for the apachesolr_attachments module.
Code
function apachesolr_attachments_update_7003() {
module_load_include('module', 'apachesolr_attachments');
// Drop our legacy table
if (db_table_exists('apachesolr_attachments_files')) {
db_drop_table('apachesolr_attachments_files');
}
$types = array(
'file' => 'apachesolr_index_entities_file',
);
foreach ($types as $type => $table) {
$schema[$table] = array(
'description' => t('Stores a record of when an entity changed to determine if it needs indexing by Solr.'),
'fields' => array(
'entity_type' => array(
'description' => t('The type of entity.'),
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
),
'entity_id' => array(
'description' => t('The primary identifier for an entity.'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'bundle' => array(
'description' => t('The bundle to which this entity belongs.'),
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
),
'status' => array(
'description' => t('Boolean indicating whether the entity is visible to non-administrators (eg, published for nodes).'),
'type' => 'int',
'not null' => TRUE,
'default' => 1,
),
'changed' => array(
'description' => t('The Unix timestamp when an entity was changed.'),
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'parent_entity_type' => array(
'description' => t('The type of entity.'),
'type' => 'varchar',
'length' => 128,
'not null' => FALSE,
),
'parent_entity_id' => array(
'description' => t('The type of the parent entity.'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
),
'hash' => array(
'description' => "A hash of the file's body, to check for changes.",
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'body' => array(
'description' => 'The cached body (extracted text) of the file, unless it is a text file.',
'type' => 'blob',
'not null' => FALSE,
'size' => 'big',
),
),
'indexes' => array(
'changed' => array(
'changed',
'status',
),
),
'primary key' => array(
'entity_id',
'parent_entity_id',
),
);
if (!db_table_exists($table)) {
db_create_table('apachesolr_index_entities_file', $schema[$table]);
}
}
// Sleep 1 second, so the table is initialized before we continue.
// See #1672768
sleep(1);
// Remove old variables
variable_del('apachesolr_attachments_exclude_types');
variable_del('apachesolr_attachments_cron_limit');
variable_del('apachesolr_attachments_cron_time_limit');
variable_del('apachesolr_attachments_cron_try');
// Repopulate our file table
apachesolr_attachments_solr_reindex();
}