Allow modules to alter the schema for a field.

Parameters

array $schema: The schema definition as returned by hook_field_schema().

array $field: The field definition.

See also

field_retrieve_schema()

Related topics

1 function implements hook_field_schema_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

field_test_schema_alter_field_schema_alter in modules/field/tests/field_test_schema_alter.install
Implements hook_field_schema_alter().

File

modules/field/field.api.php, line 291
Hooks provided by the Field module.

Code

function hook_field_schema_alter(&$schema, $field) {
  if ($field['type'] == 'image') {

    // Alter the length of a field.
    $schema['columns']['alt']['length'] = 2048;

    // Add an additional column of data.
    $schema['columns']['additional_column'] = array(
      'description' => "Additional column added to image field table.",
      'type' => 'varchar',
      'length' => 128,
      'not null' => FALSE,
    );

    // Add an additional index.
    $schema['indexes']['fid_additional_column'] = array(
      'fid',
      'additional_column',
    );
  }
}