function bat_event_create_event_type_schema in Booking and Availability Management Tools for Drupal 7
Same name and namespace in other branches
- 8 modules/bat_event/bat_event.module \bat_event_create_event_type_schema()
Create 6 tables for store events of type $machine_name.
Parameters
string $machine_name:
1 call to bat_event_create_event_type_schema()
- BatEventTypeController::save in modules/
bat_event/ bat_event.module
File
- modules/
bat_event/ bat_event.module, line 2052 - Manage Events - Events store the EventValue of a Unit over a period of time.
Code
function bat_event_create_event_type_schema($machine_name) {
$schema = array();
$schema['bat_event_' . $machine_name . '_day_state'] = array(
'description' => 'Holds the state of each unit for a given day',
'fields' => bat_event_generate_day_schema_fields(),
'indexes' => array(
'unit_id' => array(
'unit_id',
),
'year' => array(
'year',
),
'month' => array(
'month',
),
),
'unique keys' => array(
'month_key' => array(
'unit_id',
'year',
'month',
),
),
'foreign keys' => array(
'unit_id' => array(
'table' => 'bat_units',
'columns' => array(
'unit_id' => 'unit_id',
),
),
),
);
$schema['bat_event_' . $machine_name . '_day_event'] = array(
'description' => 'Holds the event that determined the state of a unit',
'fields' => bat_event_generate_day_schema_fields(),
'indexes' => array(
'unit_id' => array(
'unit_id',
),
'year' => array(
'year',
),
'month' => array(
'month',
),
),
'unique keys' => array(
'month_key' => array(
'unit_id',
'year',
'month',
),
),
'foreign keys' => array(
'unit_id' => array(
'table' => 'bat_units',
'columns' => array(
'unit_id' => 'unit_id',
),
),
),
);
$schema['bat_event_' . $machine_name . '_hour_state'] = array(
'description' => 'Holds the state of the unit',
'fields' => bat_event_generate_hour_schema_fields(),
'indexes' => array(
'unit_id' => array(
'unit_id',
),
'year' => array(
'year',
),
'month' => array(
'month',
),
),
'unique keys' => array(
'day_key' => array(
'unit_id',
'year',
'month',
'day',
),
),
'foreign keys' => array(
'unit_id' => array(
'table' => 'bat_units',
'columns' => array(
'unit_id' => 'unit_id',
),
),
),
);
$schema['bat_event_' . $machine_name . '_hour_event'] = array(
'description' => 'Holds the event that determined the state of a unit',
'fields' => bat_event_generate_hour_schema_fields(),
'indexes' => array(
'unit_id' => array(
'unit_id',
),
'year' => array(
'year',
),
'month' => array(
'month',
),
),
'unique keys' => array(
'day_key' => array(
'unit_id',
'year',
'month',
'day',
),
),
'foreign keys' => array(
'unit_id' => array(
'table' => 'bat_units',
'columns' => array(
'unit_id' => 'unit_id',
),
),
),
);
$schema['bat_event_' . $machine_name . '_minute_state'] = array(
'description' => 'Holds the state of the unit',
'fields' => bat_event_generate_minute_schema_fields(),
'indexes' => array(
'unit_id' => array(
'unit_id',
),
'year' => array(
'year',
),
'month' => array(
'month',
),
),
'unique keys' => array(
'day_key' => array(
'unit_id',
'year',
'month',
'day',
'hour',
),
),
'foreign keys' => array(
'unit_id' => array(
'table' => 'bat_units',
'columns' => array(
'unit_id' => 'unit_id',
),
),
),
);
$schema['bat_event_' . $machine_name . '_minute_event'] = array(
'description' => 'Holds the event that determined the state of a unit',
'fields' => bat_event_generate_minute_schema_fields(),
'indexes' => array(
'unit_id' => array(
'unit_id',
),
'year' => array(
'year',
),
'month' => array(
'month',
),
),
'unique keys' => array(
'day_key' => array(
'unit_id',
'year',
'month',
'day',
'hour',
),
),
'foreign keys' => array(
'unit_id' => array(
'table' => 'bat_units',
'columns' => array(
'unit_id' => 'unit_id',
),
),
),
);
foreach ($schema as $name => $table) {
db_create_table($name, $table);
}
}