You are here

function google_analytics_counter_schema in Google Analytics Counter 7.2

Same name and namespace in other branches
  1. 8.3 google_analytics_counter.install \google_analytics_counter_schema()
  2. 7.3 google_analytics_counter.install \google_analytics_counter_schema()

Implements hook_schema(). See http://drupal.org/node/146939

1 call to google_analytics_counter_schema()
google_analytics_counter_update_7201 in ./google_analytics_counter.install
Add the google_analytics_counter table for the Google Analytics Counter module.

File

./google_analytics_counter.install, line 52
Install, update, and uninstall functions for the Google Analytics Counter module.

Code

function google_analytics_counter_schema() {
  $schema['google_analytics_counter'] = array(
    'description' => 'Google Analytics data storage.',
    'fields' => array(
      'pagepath_hash' => array(
        'type' => 'varchar',
        'length' => 32,
        'description' => 'md5 hash of the relative page path.',
        'not null' => TRUE,
      ),
      'pagepath' => array(
        'type' => 'varchar',
        // varchar faster than text on MySQL (not creating temp table on disk); see http://drupal.org/node/146939#comment-2281846
        'length' => 2048,
        // see http://stackoverflow.com/a/417184/269383
        'description' => 'Relative page path, for example "node/1" or "contact", as stored by GA.',
        'not null' => TRUE,
      ),
      'pageviews' => array(
        'type' => 'int',
        'size' => 'big',
        // big int unsigned: 8 B (18446744073709551615)
        'description' => 'Pageview count.',
        'unsigned' => TRUE,
        'default' => 0,
        'not null' => TRUE,
      ),
    ),
    'primary key' => array(
      'pagepath_hash',
    ),
    'indexes' => array(
      'pagepath' => array(
        array(
          'pagepath',
          20,
        ),
      ),
      'pageviews' => array(
        'pageviews',
      ),
    ),
  );
  return $schema;
}