I'm trying to create a field with an additional property (or column) to define an extra relationship to a taxonomy term.
I have this in my module file:
/**
* Implements hook_field_info().
*/
function emtr_field_info() {
return array(
// We name our field as the associative name of the array.
'field_emtr_denominations' => array(
'label' => t('Denominations'),
'description' => t('Field linked to target entity as well as denomination taxonomy term holding denomnation value.'),
'default_widget' => 'number',
'default_formatter' => 'number_decimal',
),
);
}
And this in my install file:
/**
* Implements hook_field_schema().
*/
function emtr_field_schema($field) {
$columns = array(
'denomination_value' => array(
'type' => 'int',
'not null' => FALSE,
),
'denomination_tid' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
);
$indexes = array(
'denomination_tid' => array('denomination_tid'),
);
return array(
'columns' => $columns,
'indexes' => $indexes,
);
}
/**
* Implements hook_enable().
*/
function emtr_enable() {
field_cache_clear();
field_associate_fields('emtr');
if (field_info_field('emtr_denominations')) return;
// Create a field for denominations to be used by safe checks and till reads
$field = array(
'field_name' => 'emtr_denominations',
'type' => 'field_emtr_denominations',
'cardinality' => FIELD_CARDINALITY_UNLIMITED,
'translatable' => FALSE,
);
field_create_field($field);
// Attach the emtr_denominations reference field to safe checks instance
$instance = array(
'field_name' => 'emtr_denominations',
'entity_type' => 'emtr_safe_check',
'bundle' => 'emtr_safe_check',
'label' => 'Denominations',
'required' => false,
'widget' => array(
'type' => 'number'
),
'settings' => array(
'target_type' => 'emtr_safe_check',
'handler_settings' => array('target_bundles' => NULL),
),
'display' => array(
'default' => array('label' => 'inline', 'type' => 'number_integer'),
),
);
field_create_instance($instance);
}
But after uninstalling and re-enabling my module (drush devel-reinstall emtr -y ) a table called field_data_emtr_denominations is created but it does not have my 2 custom columns.
At what point in this process should I tell Drupal to use my custom field_schema?