You are here

function tracker_schema in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/tracker/tracker.install \tracker_schema()
  2. 7 modules/tracker/tracker.install \tracker_schema()
  3. 9 core/modules/tracker/tracker.install \tracker_schema()

Implements hook_schema().

File

core/modules/tracker/tracker.install, line 31
Install, update, and uninstall functions for tracker.module.

Code

function tracker_schema() {
  $schema['tracker_node'] = [
    'description' => 'Tracks when nodes were last changed or commented on.',
    'fields' => [
      'nid' => [
        'description' => 'The {node}.nid this record tracks.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'published' => [
        'description' => 'Boolean indicating whether the node is published.',
        'type' => 'int',
        'not null' => FALSE,
        'default' => 0,
        'size' => 'tiny',
      ],
      'changed' => [
        'description' => 'The Unix timestamp when the node was most recently saved or commented on.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
    ],
    'indexes' => [
      'tracker' => [
        'published',
        'changed',
      ],
    ],
    'primary key' => [
      'nid',
    ],
    'foreign keys' => [
      'tracked_node' => [
        'table' => 'node',
        'columns' => [
          'nid' => 'nid',
        ],
      ],
    ],
  ];
  $schema['tracker_user'] = [
    'description' => 'Tracks when nodes were last changed or commented on, for each user that authored the node or one of its comments.',
    'fields' => [
      'nid' => [
        'description' => 'The {node}.nid this record tracks.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'uid' => [
        'description' => 'The {users}.uid of the node author or commenter.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'published' => [
        'description' => 'Boolean indicating whether the node is published.',
        'type' => 'int',
        'not null' => FALSE,
        'default' => 0,
        'size' => 'tiny',
      ],
      'changed' => [
        'description' => 'The Unix timestamp when the node was most recently saved or commented on.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
    ],
    'indexes' => [
      'tracker' => [
        'uid',
        'published',
        'changed',
      ],
    ],
    'primary key' => [
      'nid',
      'uid',
    ],
    'foreign keys' => [
      'tracked_node' => [
        'table' => 'node',
        'columns' => [
          'nid' => 'nid',
        ],
      ],
      'tracked_user' => [
        'table' => 'users',
        'columns' => [
          'uid' => 'uid',
        ],
      ],
    ],
  ];
  return $schema;
}