You are here

function ref_field_field_schema in (Entity)Reference Field Synchronization 7

Implements hook_field_schema().

File

./ref_field.install, line 11
Install, update and uninstall functions for the reference field module.

Code

function ref_field_field_schema($field) {
  switch ($field['type']) {
    case 'ref_field':
      $columns = array(
        'eid' => array(
          'type' => 'int',
          'unsigned' => TRUE,
          'not null' => TRUE,
        ),
      );
      $indexes = array(
        'eid' => array(
          'eid',
        ),
      );
      $foreign = array();

      // TODO: Is this legal?
      if (isset($field['base table'])) {
        $foreign = array(
          'eid' => array(
            'table' => $field['base table'],
            'columns' => array(
              'eid' => $field['entity keys']['id'],
            ),
          ),
        );
      }
      break;
  }
  return array(
    'columns' => $columns,
    'indexes' => $indexes,
    'foreign keys' => $foreign,
  );
}