How to change a field type from Integer to Decimal? I have a content type with an integer content field. The field needs to contain float data. What's the easiest way to change the field type from integer to decimal? (There are thousands of existing nodes I will have to convert). 



I've found a solution in this comment and this comment. Is it the best?
Just to merge all the previous suggestions into one convenient chunk:

// Change this to your field name, obvs.
$field = 'field_myfieldname';

// Update the storage tables
$tables = array('field_data', 'field_revision');
foreach ($tables as $table) {
  $tablename = $table .'_'. $field;
  $fieldname = $field .'_value';
  db_change_field($tablename, $fieldname, $fieldname, array(
    'type' =&gt; 'numeric',
    'precision' =&gt; 10,
    'scale' =&gt; 2,
    'not null' =&gt; FALSE,
  ));
}

// Fetch the current field configuration
$field_config = db_query("SELECT data FROM {field_config} WHERE field_name = :field_name", array(
    ':field_name' =&gt; $field,
  ))
  -&gt;fetchObject();
$data = unserialize($field_config-&gt;data);

// Update the settings entry
$data['settings'] = array(
  'precision' =&gt; 10,
  'scale' =&gt; 2,
  'decimal_separator' =&gt; '.',
);

// Store the new field config, update the field type at the same time
db_update('field_config')
  -&gt;fields(array(
    'data' =&gt; serialize($data),
    'type' =&gt; 'number_decimal',
  ))
  -&gt;condition('field_name', $field)
  -&gt;execute();    

// If you are confident about what bundles have instances of this field you can
// go straight to the db_query with a hardcoded entity_type / bundle.
$instances = field_info_field_map();
foreach ($instances[$field]['bundles'] as $entity_type =&gt; $bundles) {
  foreach ($bundles as $bundle) {

    // Fetch the field instance data
    $field_config_instance = db_query("SELECT data FROM {field_config_instance}
                                       WHERE field_name = :field_name
                                       AND entity_type = :entity_type
                                       AND bundle = :bundle", array(
        ':field_name' =&gt; $field,
        ':entity_type' =&gt; $entity_type,
        ':bundle' =&gt; $bundle,
      ))
      -&gt;fetchObject();
    $data = unserialize($field_config_instance-&gt;data);

    // Update it with the new display type
    $data['display']['default']['type'] = 'number_decimal';

    // Store it back to the database
    db_update('field_config_instance')
      -&gt;fields(array('data' =&gt; serialize($data)))
      -&gt;condition('field_name', $field)
      -&gt;condition('entity_type', $entity_type)
      -&gt;condition('bundle', $bundle)
      -&gt;execute();

  }
}