function availability_calendar_schema in Availability Calendars 7.5
Same name and namespace in other branches
- 7.3 availability_calendar.install \availability_calendar_schema()
- 7.4 availability_calendar.install \availability_calendar_schema()
Implements hook_schema() @link http://api.drupal.org/api/drupal/modules--system--system.api.php/functio...
File
- ./
availability_calendar.install, line 10
Code
function availability_calendar_schema() {
$schema = array();
// Singular table names (though [#140860] isn't clear about the conclusion).
$schema['availability_calendar_calendar'] = array(
'description' => 'Stores availability calendars.',
'fields' => array(
'cid' => array(
'description' => 'The primary identifier for an availability calendar.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'created' => array(
'description' => 'The Unix timestamp when the calendar was created.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'changed' => array(
'description' => 'The Unix timestamp when the calendar was most recently saved.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'cid',
),
);
$schema['availability_calendar_availability'] = array(
'description' => 'Stores availability per availability calendar per day.',
'fields' => array(
'cid' => array(
'description' => 'The primary identifier for an availability calendar.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
// [#747036]: using date instead of separate fields allows for better querying.
// [#1083198]: Mysql, pgsql, mssql, and Oracle support the DATE type, but
// this is not a type supported by Drupal, so specify per supported
// database. Sqlite uses TEXT as type but has a lot of date functions.
// 'yyyy-mm-dd' (iso 8601) is accepted by mysql, pgsql, mssql, and sqlite
// to specify DATE's. For Oracle I could not find this information.
// The 'between' operator is inclusive on both sides on all databases:
// date between from and to <=> from <= date and date <= to.
'date' => array(
'description' => 'Date of availability state.',
'mysql_type' => 'DATE',
'pgsql_type' => 'DATE',
'sqlsrv_type' => 'DATE',
'oracle_type' => 'DATE',
'sqlite_type' => 'TEXT',
'type' => 'char',
'length' => '10',
'not null' => TRUE,
),
'sid' => array(
'description' => 'The availability state.',
'type' => 'int',
'size' => 'tiny',
'unsigned' => TRUE,
'not null' => TRUE,
),
),
'primary key' => array(
'cid',
'date',
),
'indexes' => array(
'availability_calendar_availability_date' => array(
'date',
'sid',
),
),
'foreign keys' => array(
'availability_calendar_calendar' => array(
'table' => 'availability_calendar_calendar',
'columns' => array(
'cid' => 'cid',
),
),
'availability_calendar_state' => array(
'table' => 'availability_calendar_state',
'columns' => array(
'sid' => 'sid',
),
),
),
);
$schema['availability_calendar_state'] = array(
'description' => 'Stores defined availability calendar states.',
'fields' => array(
'sid' => array(
'description' => 'The identifier for a state.',
'type' => 'serial',
'size' => 'tiny',
'not null' => TRUE,
),
'css_class' => array(
'description' => 'The CSS class used for this state.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
),
'label' => array(
'description' => 'The label for this state.',
'type' => 'varchar',
'length' => 64,
),
'weight' => array(
'description' => 'The weight of this state.',
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
),
'is_available' => array(
'description' => 'Boolean indicating whether this state is to be treated as available.',
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'sid',
),
);
return $schema;
}