You are here

function ad_eck_entity_type_insert in Advertisement 7.3

Implements hook_eck_entity_type_insert().

Note that this is triggered when a type is added, not when an entity is created.

File

./ad.module, line 636
Core code for the ad module.

Code

function ad_eck_entity_type_insert($entity_type) {

  // Add an index which is used in the stats view.
  if ($entity_type->data['name'] == 'tracked_event') {
    if (!db_index_exists('eck_tracked_event', 'ad')) {

      // Be optimistic and use a BIGINT as event id.
      $table = 'eck_tracked_event';
      $definition = array(
        'description' => 'The primary identifier for a(n) tracked_event.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'size' => 'big',
        'not null' => TRUE,
      );
      db_change_field($table, 'id', 'id', $definition);

      // Also add an index which is used often.
      db_add_index($table, 'ad', array(
        'ad',
      ));
      db_add_index($table, 'unique_id', array(
        'unique_id',
      ));
      db_add_index($table, 'parent_unique_id', array(
        'parent_unique_id',
      ));
    }
  }
}