You are here

function rooms_update_7001 in Rooms - Drupal Booking for Hotels, B&Bs and Vacation Rentals 7

Converts the booking option price value columns from integer to float.

File

./rooms.install, line 115
Install, update and uninstall functions for the rooms module.

Code

function rooms_update_7001() {
  $spec = array(
    'type' => 'float',
    'not null' => FALSE,
  );
  $fields = array_filter(field_info_fields(), function ($item) {
    return $item['type'] == 'rooms_options';
  });
  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'] . '_value';
    db_change_field($data_table, $field, $field, $spec);
    db_change_field($revision_table, $field, $field, $spec);
  }
  return t('Field structure updated.');
}