function geofield_update_7200 in Geofield 7.2
Change geofield lat, lon, left, top, right and bottom from floats to numeric fields with precision of 18 and scale of 12.
File
- ./
geofield.install, line 152 - Install, update and uninstall functions for the geofield module.
Code
function geofield_update_7200() {
if (!module_exists('field_sql_storage')) {
return;
}
$field_keys = array(
'lat',
'lon',
'left',
'top',
'right',
'bottom',
);
foreach (field_info_fields() as $field_name => $field) {
if ($field['type'] != 'geofield') {
// Not a geofield field.
continue;
}
if ($field['storage']['type'] !== 'field_sql_storage') {
// Field doesn't use SQL storage, we cannot modify the schema.
continue;
}
$table_name = _field_sql_storage_tablename($field);
$revision_table_name = _field_sql_storage_revision_tablename($field);
foreach ($field_keys as $field_key) {
db_change_field($table_name, $field_name . '_' . $field_key, $field_name . '_' . $field_key, array(
'type' => 'numeric',
'precision' => 18,
'scale' => 12,
'not null' => FALSE,
));
db_change_field($revision_table_name, $field_name . '_' . $field_key, $field_name . '_' . $field_key, array(
'type' => 'numeric',
'precision' => 18,
'scale' => 12,
'not null' => FALSE,
));
}
}
}