View source
<?php
function taxonomy_entity_index_schema() {
$schema['taxonomy_entity_index'] = array(
'description' => 'Maintains denormalized information about entity/term relationships.',
'fields' => array(
'entity_type' => array(
'description' => 'The entity type this term is attached to.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
),
'bundle' => array(
'description' => 'The entity bundle this term is attached to.',
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
),
'entity_id' => array(
'description' => 'The entity ID this term is attached to.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'revision_id' => array(
'description' => 'The entity revision ID this term is attached to.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'field_name' => array(
'description' => 'The field name the term is attached to.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
),
'delta' => array(
'description' => 'The delta order of the term in the field.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'tid' => array(
'description' => 'The term ID.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'entity_type',
'entity_id',
'revision_id',
'field_name',
'delta',
),
'indexes' => array(
'field_instance' => array(
'field_name',
'entity_type',
'bundle',
),
'tid' => array(
'tid',
),
),
'foreign keys' => array(
'term' => array(
'table' => 'taxonomy_term_data',
'columns' => array(
'tid' => 'tid',
),
),
),
);
return $schema;
}
function taxonomy_entity_index_update_7000() {
db_add_field('taxonomy_entity_index', 'delta', array(
'description' => 'The delta order of the term.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
));
}
function taxonomy_entity_index_update_7001() {
db_drop_primary_key('taxonomy_entity_index');
db_change_field('taxonomy_entity_index', 'entity_type', 'entity_type', array(
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
));
db_add_field('taxonomy_entity_index', 'field_name', array(
'description' => 'The field name the term is attached to.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
));
db_add_primary_key('taxonomy_entity_index', array(
'entity_type',
'entity_id',
'revision_id',
'field_name',
'delta',
));
}
function taxonomy_entity_index_update_7002() {
db_add_field('taxonomy_entity_index', 'bundle', array(
'description' => 'The entity bundle this term is attached to.',
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
));
db_add_index('taxonomy_entity_index', 'field_instance', array(
'field_name',
'entity_type',
'bundle',
));
}
function taxonomy_entity_index_update_7003() {
db_add_index('taxonomy_entity_index', 'tid', array(
'tid',
));
}
function taxonomy_entity_index_update_7004() {
db_drop_primary_key('taxonomy_entity_index');
db_change_field('taxonomy_entity_index', 'revision_id', 'revision_id', array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
));
db_add_primary_key('taxonomy_entity_index', array(
'entity_type',
'entity_id',
'revision_id',
'field_name',
'delta',
));
}