Last active
August 29, 2015 14:10
-
-
Save plopesc/5cfccb1784d62bcb4e25 to your computer and use it in GitHub Desktop.
Update the column structure for a field type.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Converts the value column from integer to float. | |
*/ | |
function mymodule_update_70XX() { | |
$spec = array( | |
'type' => 'float', | |
'not null' => FALSE, | |
); // DB Column definition. | |
$field_name = 'your_field_name'; | |
$field_column = 'your_column_name'; | |
$fields = array_filter(field_info_fields(), function($item) use ($field_name) { | |
return $item['type'] == $field_name; | |
}); | |
foreach ($fields as $field_definition) { | |
$data_table = 'field_data_' . $field_definition['field_name']; | |
$revision_table = 'field_revision_' . $field_definition['field_name']; | |
$field = $field_definition['field_name'] . '_' . $field_column; | |
db_change_field($data_table, $field, $field, $spec); | |
db_change_field($revision_table, $field, $field, $spec); | |
} | |
return t('Field structure updated.'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment