function bat_event_schema in Booking and Availability Management Tools for Drupal 7
Implements hook_schema().
File
- modules/
bat_event/ bat_event.install, line 51 - Sets up the base table for our entity and a table to store information about the entity types.
Code
function bat_event_schema() {
$schema = array();
$schema['bat_events'] = array(
'description' => 'The base table for Events.',
'fields' => array(
'event_id' => array(
'description' => 'Primary Key: Identifier for an Event.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'type' => array(
'description' => 'The type of this Event.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'language' => array(
'description' => 'The language of the Event.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
),
'created' => array(
'description' => 'The Unix timestamp when the Event was created.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'changed' => array(
'description' => 'The Unix timestamp when the Event was most recently saved.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'uid' => array(
'description' => 'The {users}.uid that owns this event.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'start_date' => array(
'type' => 'datetime',
'mysql_type' => 'datetime',
'pgsql_type' => 'timestamp without time zone',
'sqlite_type' => 'varchar',
'sqlsrv_type' => 'smalldatetime',
'not null' => FALSE,
'description' => 'The start date for the event.',
),
'end_date' => array(
'type' => 'datetime',
'mysql_type' => 'datetime',
'pgsql_type' => 'timestamp without time zone',
'sqlite_type' => 'varchar',
'sqlsrv_type' => 'smalldatetime',
'not null' => FALSE,
'description' => 'The end date for the event.',
),
'data' => array(
'type' => 'blob',
'not null' => FALSE,
'size' => 'big',
'serialize' => TRUE,
'description' => 'A serialized array of additional data.',
),
),
'primary key' => array(
'event_id',
),
'indexes' => array(
'event_id' => array(
'event_id',
),
'type' => array(
'type',
),
'uid' => array(
'uid',
),
),
);
$schema['bat_event_type'] = array(
'description' => 'Stores information about defined event types.',
'fields' => array(
'id' => array(
'type' => 'serial',
'not null' => TRUE,
'description' => 'Primary Key: Unique event type identifier.',
),
'type' => array(
'description' => 'The machine-readable name of this event type.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
'label' => array(
'description' => 'The human-readable name of this event type.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'event_granularity' => array(
'description' => 'Event Granularity (bat_daily/bat_hourly).',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => 'daily',
),
'fixed_event_states' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'Fixed event states (0/1).',
),
'weight' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
'description' => 'The weight of this event type in relation to others.',
),
'default_event_value_field_ids' => array(
'type' => 'text',
'not null' => FALSE,
'size' => 'big',
'serialize' => TRUE,
'description' => 'A serialized array that stores this type bundle\'s default event field configuration.',
),
'default_event_label_field_name' => array(
'type' => 'varchar',
'not null' => FALSE,
'length' => 32,
'description' => 'The name of a field to use to retrieve label information.',
),
'data' => array(
'type' => 'text',
'not null' => FALSE,
'size' => 'big',
'serialize' => TRUE,
'description' => 'A serialized array of additional data related to this event 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,
),
'target_entity_type' => array(
'description' => 'The machine name of the target entity type for this event type.',
'type' => 'varchar',
'length' => 32,
'not null' => FALSE,
),
),
'primary key' => array(
'id',
),
'unique keys' => array(
'type' => array(
'type',
),
),
);
$schema['bat_event_state'] = array(
'description' => 'Stores information about defined event states.',
'fields' => array(
'id' => array(
'type' => 'int',
'not null' => TRUE,
'description' => 'Primary Key: Unique event state identifier.',
),
'machine_name' => array(
'description' => 'Machine name.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
'event_type' => array(
'description' => 'Event type machine name.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
'label' => array(
'description' => 'The human-readable name of this event state.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'color' => array(
'description' => 'The color hex.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'calendar_label' => array(
'description' => 'The calendar label.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'locked' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
'description' => 'Lock.',
),
'blocking' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
'description' => 'Blocking.',
),
'default_state' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
'description' => 'Default state.',
),
),
'primary key' => array(
'id',
),
);
return $schema;
}