You are here

analytics.install in Analytics 6

Same filename and directory in other branches
  1. 7 analytics.install

File

analytics.install
View source
<?php

/**
 * Implementation of hook_schema().
 */
function analytics_schema() {
  $schema = array();
  $schema['analytics_events'] = array(
    'description' => 'A list of all recorded analytics events.',
    'fields' => array(
      'id' => array(
        'description' => 'Event ID, used to join against {analytics_property_instance}.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'event_name' => array(
        'description' => 'Text representation of the event.',
        'type' => 'varchar',
        'length' => '255',
        'not null' => FALSE,
      ),
    ),
    'primary key' => array(
      'id',
    ),
    'indexes' => array(
      'event_name' => array(
        'event_name',
      ),
    ),
  );
  $schema['analytics_properties'] = array(
    'description' => 'A list of all properties belong to all events.',
    'fields' => array(
      'id' => array(
        'description' => 'The property ID, user to join against {analytics_property_instance}.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'property_name' => array(
        'description' => 'Text representation of the property.',
        'type' => 'varchar',
        'length' => '255',
        'not null' => FALSE,
      ),
    ),
    'primary key' => array(
      'id',
    ),
    'indexes' => array(
      'property_name' => array(
        'property_name',
      ),
    ),
  );
  $schema['analytics_property_instance'] = array(
    'description' => 'This table stores relation between analytics events, and analytics properties.',
    'fields' => array(
      'id' => array(
        'description' => 'Property instance ID, used to join against {analytics_property_values}.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'event_id' => array(
        'description' => 'Event ID, used to join against {analytics_events}.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'property_id' => array(
        'description' => 'Property ID, used to join against {analytics_properties}.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'id',
    ),
    'indexes' => array(
      'event_id' => array(
        'event_id',
      ),
      'property_id' => array(
        'property_id',
      ),
    ),
  );
  $schema['analytics_property_values'] = array(
    'description' => 'Storage for event properties',
    'fields' => array(
      'id' => array(
        'description' => 'Property storage ID.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'property_id' => array(
        'description' => 'Property ID, used to join aganst {analytics_properties}.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'event_instance_id' => array(
        'description' => 'Property ID, used to join aganst {analytics_properties}.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'value' => array(
        'description' => 'The value for this property, ',
        'type' => 'varchar',
        'length' => '255',
        'not null' => FALSE,
      ),
    ),
    'primary key' => array(
      'id',
    ),
    'indexes' => array(
      'property_id' => array(
        'property_id',
      ),
      'event_instance_id' => array(
        'event_instance_id',
      ),
      'value' => array(
        'value',
      ),
    ),
  );
  $schema['analytics_event_instance'] = array(
    'description' => 'Storage for events',
    'fields' => array(
      'id' => array(
        'description' => 'Event instance ID.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'event_id' => array(
        'description' => 'Event ID, used to join aganst {analytics_events}.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'date' => array(
        'description' => 'Date of this event.',
        'type' => 'datetime',
        'not null' => TRUE,
      ),
      'year' => array(
        'description' => 'Year of the event.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'month' => array(
        'description' => 'Month of the event.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'week' => array(
        'description' => 'Week of the event.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'ip' => array(
        'description' => 'IP address associated with this event.',
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
      ),
      'unique_id' => array(
        'description' => 'A unique ID associated with this event.',
        'type' => 'varchar',
        'length' => '255',
        'not null' => FALSE,
      ),
    ),
    'primary key' => array(
      'id',
    ),
    'indexes' => array(
      'event_id' => array(
        'event_id',
      ),
      'date' => array(
        'date',
      ),
      'month' => array(
        'month',
      ),
      'week' => array(
        'week',
      ),
      'year' => array(
        'year',
      ),
      'ip' => array(
        'ip',
      ),
    ),
  );
  return $schema;
}

/**
 * Implementation of hook_install().
 */
function analytics_install() {
  drupal_install_schema('analytics');
}

/**
 * Implementation of hook_uninstall().
 */
function analytics_uninstall() {
  drupal_uninstall_schema('analytics');
}

Functions

Namesort descending Description
analytics_install Implementation of hook_install().
analytics_schema Implementation of hook_schema().
analytics_uninstall Implementation of hook_uninstall().