You are here

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

Add the booking option Type column.

File

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

Code

function rooms_update_7002() {
  $fields = field_info_fields();
  foreach ($fields as $field) {
    if ($field['type'] == 'rooms_options') {
      $revision_table = key($field['storage']['details']['sql']['FIELD_LOAD_REVISION']);
      $field_name = $field['storage']['details']['sql']['FIELD_LOAD_REVISION'][$revision_table]['type'];
      if (!db_field_exists($revision_table, $field_name)) {
        $field_spec = $field['columns']['type'];
        $field_spec['initial'] = 'optional';
        db_add_field($revision_table, $field_name, $field_spec);
      }
      $current_table = key($field['storage']['details']['sql']['FIELD_LOAD_CURRENT']);
      $field_name = $field['storage']['details']['sql']['FIELD_LOAD_CURRENT'][$current_table]['type'];
      if (!db_field_exists($current_table, $field_name)) {
        $field_spec = $field['columns']['type'];
        $field_spec['initial'] = 'optional';
        db_add_field($current_table, $field_name, $field_spec);
      }
    }
  }
}