Define the Field API schema for a field structure.
This is invoked when a field is created, in order to obtain the database schema from the module that defines the field's type.
This hook must be defined in the module's .install file for it to be detected during installation and upgrade.
$field: A field structure.
An associative array with the following keys:
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
function hook_field_schema($field) {
if ($field['type'] == 'text_long') {
$columns = array(
'value' => array(
'type' => 'text',
'size' => 'big',
'not null' => FALSE,
),
);
}
else {
$columns = array(
'value' => array(
'type' => 'varchar',
'length' => $field['settings']['max_length'],
'not null' => FALSE,
),
);
}
$columns += array(
'format' => array(
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
),
);
return array(
'columns' => $columns,
'indexes' => array(
'format' => array(
'format',
),
),
'foreign keys' => array(
'format' => array(
'table' => 'filter_format',
'columns' => array(
'format' => 'format',
),
),
),
);
}