function availability_calendars_schema in Availability Calendars 7.2
Same name and namespace in other branches
- 6.2 availability_calendars.install \availability_calendars_schema()
- 6 availability_calendars.install \availability_calendars_schema()
Implements hook_schema().
@todo?: http://drupal.org/node/111011: Add foreign keys to core
See also
http://api.drupal.org/api/drupal/modules--system--system.api.php/functio...
2 calls to availability_calendars_schema()
- availability_calendars_update_6200 in ./
availability_calendars.install - Add custom states (issue #306461)
- availability_calendars_update_7204 in ./
availability_calendars.install - Add a boolean field indicating if a state "is available" to the states table of Availability Calendars.
File
- ./
availability_calendars.install, line 17 - Install, update and uninstall functions for the Availability Calendars module.
Code
function availability_calendars_schema() {
$schema = array();
$schema['availability_calendars_day'] = array(
'description' => 'The table with availability states per day.',
'fields' => array(
'nid' => array(
'description' => 'The primary identifier for a node.',
'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 DATE type. Sqlite uses TEXT as type but has a lot of date functions
// 'yyyy-mm-dd' (iso 8601) is accepted by mysql, pgsql, mssql, sqlite. 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',
'sqlite_type' => 'TEXT',
// SQLite does not have a DATE type
'not null' => TRUE,
),
'status' => array(
'description' => 'The status.',
'type' => 'varchar',
'length' => 55,
),
),
'primary key' => array(
'nid',
'date',
),
);
$schema['availability_calendars_week'] = array(
'description' => 'The table for calendar week notes.',
'fields' => array(
'nid' => array(
'description' => 'The primary identifier for a node.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'year' => array(
'description' => 'The number of the year.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'month' => array(
'description' => 'The number of the month.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'week' => array(
'description' => 'The number of the week.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'note' => array(
'description' => 'The note.',
'type' => 'varchar',
'length' => 200,
),
),
'primary key' => array(
'nid',
'year',
'month',
'week',
),
);
$schema['availability_calendars_states'] = array(
'description' => 'Store classes and labels for the possible states in availability calendars',
'fields' => array(
// @todo: rename to css class in a next update (and remove the conversion code)
'class' => array(
'description' => 'The CSS class used for this state',
'type' => 'varchar',
'length' => 24,
'not null' => TRUE,
),
'label' => array(
'description' => 'The label as displayed to users for this state',
'type' => 'varchar',
'length' => 64,
// should not be too long: will give display problems
'not null' => TRUE,
),
'weight' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
'description' => 'The weight of this state',
),
'is_available' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'Boolean indicating whether this state is to be treated as available',
),
),
'primary key' => array(
'class',
),
);
return $schema;
}