You are here

function google_map_field_update_7001 in Google Map Field 7.2

Change precision of LAT,LON fields to prevent coords being truncated.

File

./google_map_field.install, line 89
Defines schema for google_map fields.

Code

function google_map_field_update_7001() {
  $fields = google_map_field_get_fields();
  foreach ($fields as $field) {
    $table_prefixes = array(
      _field_sql_storage_tablename($field),
      _field_sql_storage_revision_tablename($field),
    );
    foreach ($table_prefixes as $table_prefix) {
      $field_name = $field['field_name'];

      // eg 'field_dimensions' ;
      $table = $table_prefix;

      // . $field_name;
      // Convert two db columns from float to double precision
      $column1 = $field_name . '_lat';
      $column2 = $field_name . '_lon';
      $spec = array(
        'type' => 'float',
        'size' => 'big',
        'default' => 0.0,
      );
      db_change_field($table, $column1, $column1, $spec);
      db_change_field($table, $column2, $column2, $spec);
    }
  }
  return t('Changed precision of LAT,LON fields to prevent coords being truncated.');
}