You are here

function bat_calendar_reference_field_schema in Booking and Availability Management Tools for Drupal 7

Implements hook_field_schema().

File

modules/bat_calendar_reference/bat_calendar_reference.install, line 12
Install, update and uninstall functions for the bat_calendar_reference module.

Code

function bat_calendar_reference_field_schema($field) {
  if ($field['type'] == 'bat_calendar_unit_reference') {
    $columns = array(
      'unit_id' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
      ),
      'event_type_id' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
      ),
    );
    return array(
      'columns' => $columns,
      'indexes' => array(
        'unit_id' => array(
          'unit_id',
        ),
      ),
      'foreign keys' => array(
        'unit_id' => array(
          'table' => 'bat_units',
          'columns' => array(
            'unit_id' => 'unit_id',
          ),
        ),
        'event_type_id' => array(
          'table' => 'bat_calendar_type',
          'columns' => array(
            'id' => 'id',
          ),
        ),
      ),
    );
  }
  elseif ($field['type'] == 'bat_calendar_unit_type_reference') {
    $columns = array(
      'unit_type_id' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
      ),
      'event_type_id' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
      ),
    );
    return array(
      'columns' => $columns,
      'indexes' => array(
        'unit_type_id' => array(
          'unit_type_id',
        ),
      ),
      'foreign keys' => array(
        'unit_type_id' => array(
          'table' => 'bat_types',
          'columns' => array(
            'type_id' => 'type_id',
          ),
        ),
        'event_type_id' => array(
          'table' => 'bat_calendar_type',
          'columns' => array(
            'id' => 'id',
          ),
        ),
      ),
    );
  }
}