1 field_test.install field_test_field_schema($field)

Implements hook_field_schema().

File

core/modules/field/tests/field_test/field_test.install, line 118
Install, update and uninstall functions for the field_test module.

Code

function field_test_field_schema($field) {
  if ($field['type'] == 'test_field') {
    return array(
      'columns' => array(
        'value' => array(
          'type' => 'int',
          'size' => 'medium',
          'not null' => FALSE,
        ),
      ),
      'indexes' => array(
        'value' => array('value'),
      ),
    );
  }
  else {
    $foreign_keys = array();
    // The 'foreign keys' key is not always used in tests.
    if (!empty($field['settings']['foreign_key_name'])) {
      $foreign_keys['foreign keys'] = array(
        // This is a dummy foreign key definition, references a table that
        // doesn't exist, but that's not a problem.
        $field['settings']['foreign_key_name'] => array(
          'table' => $field['settings']['foreign_key_name'],
          'columns' => array($field['settings']['foreign_key_name'] => 'id'),
        ),
      );
    }
    return array(
      'columns' => array(
        'shape' => array(
          'type' => 'varchar',
          'length' => 32,
          'not null' => FALSE,
        ),
        'color' => array(
          'type' => 'varchar',
          'length' => 32,
          'not null' => FALSE,
        ),
      ),
    ) + $foreign_keys;
  }
}