You are here

function google_analytics_counter_schema in Google Analytics Counter 8.3

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

Implements hook_schema().

File

./google_analytics_counter.install, line 58
Update, and uninstall functions for the Google Analytics Counter module.

Code

function google_analytics_counter_schema() {
  $schema['google_analytics_counter'] = [
    'description' => 'Stores URIs and pageviews from Google Analytics.',
    'fields' => [
      'pagepath_hash' => [
        'type' => 'varchar',
        'length' => 32,
        'description' => 'md5 hash of the relative page path.',
        'not null' => TRUE,
      ],
      'pagepath' => [
        'type' => 'varchar',
        'length' => 2048,
        'description' => 'Relative page path, for example "node/1" or "contact", as stored by GA.',
        'not null' => TRUE,
      ],
      'pageviews' => [
        'type' => 'int',
        'size' => 'big',
        'description' => 'Pageview count.',
        'unsigned' => TRUE,
        'default' => 0,
        'not null' => TRUE,
      ],
    ],
    'primary key' => [
      'pagepath_hash',
    ],
    'indexes' => [
      'pagepath' => [
        [
          'pagepath',
          20,
        ],
      ],
      'pageviews' => [
        'pageviews',
      ],
    ],
  ];
  $schema['google_analytics_counter_storage'] = [
    'description' => 'Stores node ids for nodes only that have pageview totals.',
    'fields' => [
      'nid' => [
        'description' => 'Node IDs',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ],
      'pageview_total' => [
        'description' => 'Total pageview counts',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ],
    ],
    'indexes' => [
      'nid' => [
        'nid',
      ],
      'pageview_total' => [
        'pageview_total',
      ],
    ],
  ];
  return $schema;
}