You are here

function nodeviewcount_schema in Node view count 8

Same name and namespace in other branches
  1. 7.3 nodeviewcount.install \nodeviewcount_schema()
  2. 7 nodeviewcount.install \nodeviewcount_schema()
  3. 7.2 nodeviewcount.install \nodeviewcount_schema()

Implements hook_schema().

File

./nodeviewcount.install, line 13
Install, update and uninstall functions for the nodeviewcount module.

Code

function nodeviewcount_schema() {
  $schema['nodeviewcount'] = [
    'description' => 'Node views information, including view datetime, user ID and IP address.',
    'fields' => [
      'id' => [
        'description' => 'The unique ID.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ],
      'nid' => [
        'description' => 'The node ID.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ],
      'uid' => [
        'description' => 'The ID of a user who viewed the node.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ],
      'uip' => [
        'description' => 'IP address of a user who viewed the node.',
        'type' => 'varchar',
        'length' => 100,
        'not null' => TRUE,
        'default' => 0,
      ],
      'datetime' => [
        'description' => 'The date and time when the node was viewed by the user.',
        'type' => 'varchar',
        'length' => 100,
        'not null' => TRUE,
        'default' => 0,
      ],
    ],
    'primary key' => [
      'id',
    ],
    'indexes' => [
      'nid' => [
        'nid',
      ],
      'uid' => [
        'uid',
      ],
      'datetime' => [
        'datetime',
      ],
    ],
  ];
  return $schema;
}