You are here

function google_analytics_counter_schema in Google Analytics Counter 7.3

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

Implements hook_schema().

See http://drupal.org/node/146939

2 calls to google_analytics_counter_schema()
google_analytics_counter_update_7201 in ./google_analytics_counter.install
Add the google_analytics_counter table.
google_analytics_counter_update_7301 in ./google_analytics_counter.install
Add the google_analytics_counter_storage table.

File

./google_analytics_counter.install, line 27
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',
      ),
    ),
  );
  $schema['google_analytics_counter_storage'] = array(
    'description' => 'Google Analytics Counter module table holding pageview counts.',
    'fields' => array(
      'nid' => array(
        'description' => 'Node IDs',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'pageview_total' => array(
        'description' => 'Total pageview counts',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
    ),
    'primary key' => array(
      'nid',
    ),
    'indexes' => array(
      'pageview_total' => array(
        'pageview_total',
      ),
    ),
  );
  return $schema;
}