function rooms_unit_schema in Rooms - Drupal Booking for Hotels, B&Bs and Vacation Rentals 7
Implements hook_schema().
File
- modules/
rooms_unit/ rooms_unit.install, line 37 - Sets up the base table for our entity and a table to store information about the entity types.
Code
function rooms_unit_schema() {
$schema = array();
$schema['rooms_units'] = array(
'description' => 'The base table for Rooms.',
'fields' => array(
'unit_id' => array(
'description' => 'Primary Key: Identifier for a Bookable Unit.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'type' => array(
'description' => 'The {unit_type}.type of this Bookable Unit.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'language' => array(
'description' => 'The language of the Unit.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
),
'name' => array(
'description' => 'The name of the Unit - a human-readable identifier.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'created' => array(
'description' => 'The Unix timestamp when the Unit was created.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'changed' => array(
'description' => 'The Unix timestamp when the Unit was most recently saved.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'base_price' => array(
'description' => 'The default cost per night for the unit',
'type' => 'numeric',
'not null' => TRUE,
'precision' => 10,
'scale' => 2,
'default' => 0,
),
'weekly_discount' => array(
'description' => 'The default weekly discount for the unit',
'type' => 'numeric',
'not null' => TRUE,
'precision' => 10,
'scale' => 2,
'default' => 0,
),
'monthly_discount' => array(
'description' => 'The default monthly discount for the unit',
'type' => 'numeric',
'not null' => TRUE,
'precision' => 10,
'scale' => 2,
'default' => 0,
),
'default_state' => array(
'description' => 'The default booking state for the room',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'bookable' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 1,
'size' => 'tiny',
'description' => 'Whether the unit is available for booking or not.',
),
'min_sleeps' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 1,
'size' => 'tiny',
'description' => 'How many people can sleep in a unit (MIN)',
),
'max_sleeps' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 1,
'size' => 'tiny',
'description' => 'How many people can sleep in a unit (MAX)',
),
'min_children' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
'description' => 'How many children can sleep in a unit (MIN)',
),
'max_children' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
'description' => 'How many children can sleep in a unit (MAX)',
),
'status' => array(
'description' => 'Boolean indicating whether the booking unit is published (visible to non-administrators).',
'type' => 'int',
'not null' => TRUE,
'default' => 1,
),
'uid' => array(
'description' => 'The {users}.uid that created this booking.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'data' => array(
'type' => 'blob',
'not null' => FALSE,
'size' => 'big',
'serialize' => TRUE,
'description' => 'A serialized array of additional data.',
),
),
'primary key' => array(
'unit_id',
),
'indexes' => array(
'type' => array(
'type',
),
),
);
$schema['rooms_unit_type'] = array(
'description' => 'Stores information about defined unit types.',
'fields' => array(
'id' => array(
'type' => 'serial',
'not null' => TRUE,
'description' => 'Primary Key: Unique unit type identifier.',
),
'type' => array(
'description' => 'The machine-readable name of this unit type.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
'label' => array(
'description' => 'The human-readable name of this unit type.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'weight' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
'description' => 'The weight of this room type in relation to others.',
),
'data' => array(
'type' => 'text',
'not null' => FALSE,
'size' => 'big',
'serialize' => TRUE,
'description' => 'A serialized array of additional data related to this unit type.',
),
'status' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0x1,
'size' => 'tiny',
'description' => 'The exportable status of the entity.',
),
'module' => array(
'description' => 'The name of the providing module if the entity has been defined in code.',
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
),
),
'primary key' => array(
'id',
),
'unique keys' => array(
'type' => array(
'type',
),
),
);
return $schema;
}