View source
<?php
function vat_number_field_schema($field) {
$columns = array(
'value' => array(
'description' => 'VAT Number',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
);
$indexes = array(
'value' => array(
'value',
),
);
return array(
'columns' => $columns,
'indexes' => $indexes,
);
}
function vat_number_update_7001(&$sandbox = NULL) {
$ret = array();
$fields = array();
foreach (field_info_fields() as $field) {
if ($field['type'] == 'vat_number') {
$fields[] = $field;
}
}
foreach ($fields as $field) {
$tables = array(
_field_sql_storage_tablename($field),
_field_sql_storage_revision_tablename($field),
);
foreach ($tables as $table) {
$field_name = $field['field_name'];
$column_old = $field_name . '_vat_number';
$column_new = $field_name . '_value';
$spec = array(
'description' => 'Vat Number',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
);
db_change_field($table, $column_old, $column_new, $spec);
}
}
return t('Database column name updated.');
}