drupal/core/modules/entity_reference/entity_reference.install

50 lines
1.2 KiB
Plaintext

<?php
/**
* @file
* Install, update and uninstall functions for the Entity Reference
* module.
*/
/**
* Implements hook_field_schema().
*/
function entity_reference_field_schema($field) {
$schema = array(
'columns' => array(
'target_id' => array(
'description' => 'The ID of the target entity.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'revision_id' => array(
'description' => 'The revision ID of the target entity.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
),
),
'indexes' => array(
'target_id' => array('target_id'),
),
'foreign keys' => array(),
);
// Create a foreign key to the target entity type base type.
// @todo It's still not safe to call entity_get_info() in here.
// see http://drupal.org/node/1847582
// $entity_type = $field['settings']['target_type'];
// $entity_info = entity_get_info($entity_type);
//
// $base_table = $entity_info['base_table'];
// $id_column = $entity_info['entity_keys']['id'];
//
// $schema['foreign keys'][$base_table] = array(
// 'table' => $base_table,
// 'columns' => array('target_id' => $id_column),
// );
return $schema;
}