You are here

function forum_schema in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/forum/forum.install \forum_schema()
  2. 6 modules/forum/forum.install \forum_schema()
  3. 7 modules/forum/forum.install \forum_schema()
  4. 9 core/modules/forum/forum.install \forum_schema()

Implements hook_schema().

File

core/modules/forum/forum.install, line 63
Install, update, and uninstall functions for the Forum module.

Code

function forum_schema() {
  $schema['forum'] = [
    'description' => 'Stores the relationship of nodes to forum terms.',
    'fields' => [
      'nid' => [
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The {node}.nid of the node.',
      ],
      'vid' => [
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Primary Key: The {node}.vid of the node.',
      ],
      'tid' => [
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The {taxonomy_term_data}.tid of the forum term assigned to the node.',
      ],
    ],
    'indexes' => [
      'forum_topic' => [
        'nid',
        'tid',
      ],
      'tid' => [
        'tid',
      ],
    ],
    'primary key' => [
      'vid',
    ],
    'foreign keys' => [
      'forum_node' => [
        'table' => 'node',
        'columns' => [
          'nid' => 'nid',
          'vid' => 'vid',
        ],
      ],
    ],
  ];
  $schema['forum_index'] = [
    'description' => 'Maintains denormalized information about node/term relationships.',
    'fields' => [
      'nid' => [
        'description' => 'The {node}.nid this record tracks.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'title' => [
        'description' => 'The node title.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ],
      'tid' => [
        'description' => 'The term ID.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'sticky' => [
        'description' => 'Boolean indicating whether the node is sticky.',
        'type' => 'int',
        'not null' => FALSE,
        'default' => 0,
        'size' => 'tiny',
      ],
      'created' => [
        'description' => 'The Unix timestamp when the node was created.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'last_comment_timestamp' => [
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The Unix timestamp of the last comment that was posted within this node, from {comment}.timestamp.',
      ],
      'comment_count' => [
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The total number of comments on this node.',
      ],
    ],
    'indexes' => [
      'forum_topics' => [
        'nid',
        'tid',
        'sticky',
        'last_comment_timestamp',
      ],
      'created' => [
        'created',
      ],
      'last_comment_timestamp' => [
        'last_comment_timestamp',
      ],
    ],
    'foreign keys' => [
      'tracked_node' => [
        'table' => 'node',
        'columns' => [
          'nid' => 'nid',
        ],
      ],
      'term' => [
        'table' => 'taxonomy_term_data',
        'columns' => [
          'tid' => 'tid',
        ],
      ],
    ],
  ];
  return $schema;
}