You are here

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

Adds max and min sleeps, add max and min children.

File

modules/rooms_unit/rooms_unit.install, line 447
Sets up the base table for our entity and a table to store information about the entity types.

Code

function rooms_unit_update_7005() {
  $max_sleeps = array(
    'type' => 'int',
    'not null' => TRUE,
    'default' => 1,
    'size' => 'tiny',
    'description' => 'How many people can sleep in a unit (MAX)',
  );
  db_change_field('rooms_units', 'sleeps', 'max_sleeps', $max_sleeps);
  $max_children = array(
    'type' => 'int',
    'not null' => TRUE,
    'default' => 0,
    'size' => 'tiny',
    'description' => 'How many children can sleep in a unit (MAX)',
  );
  db_change_field('rooms_units', 'children', 'max_children', $max_children);
  $min_sleeps = array(
    'type' => 'int',
    'not null' => TRUE,
    'default' => 1,
    'size' => 'tiny',
    'description' => 'How many people can sleep in a unit (MIN)',
  );
  db_add_field('rooms_units', 'min_sleeps', $min_sleeps);
  $min_children = array(
    'type' => 'int',
    'not null' => TRUE,
    'default' => 0,
    'size' => 'tiny',
    'description' => 'How many children can sleep in a unit (MIN)',
  );
  db_add_field('rooms_units', 'min_children', $min_children);
  db_update('rooms_units')
    ->expression('min_sleeps', 'max_sleeps')
    ->execute();
  db_update('rooms_units')
    ->expression('min_children', 'max_children')
    ->execute();
}