You are here

function commerce_donate_update_7001 in Commerce Donate 7

Change integer amount field to decimal.

File

./commerce_donate.install, line 53
Installation file for commerce_donate. Creates necessary entity fields on installation.

Code

function commerce_donate_update_7001() {
  db_change_field('field_data_commerce_donate_amount', 'commerce_donate_amount_value', 'commerce_donate_amount_value', array(
    'type' => 'float',
    'size' => 'big',
  ));
  db_change_field('field_revision_commerce_donate_amount', 'commerce_donate_amount_value', 'commerce_donate_amount_value', array(
    'type' => 'float',
    'size' => 'big',
  ));
  $serialized = db_query("SELECT data FROM {field_config} WHERE field_name = 'commerce_donate_amount'")
    ->fetchField();
  $data = unserialize($serialized);
  $data['settings']['precision'] = 10;
  $data['settings']['scale'] = 2;
  $data['settings']['decimal_separator'] = '.';
  $serialized = serialize($data);
  db_query("UPDATE {field_config} SET type = 'number_decimal', data = :data WHERE field_name = 'commerce_donate_amount'", array(
    ':data' => $serialized,
  ));
}