function forum_schema

Same name in other branches
  1. 7.x modules/forum/forum.install \forum_schema()
  2. 9 core/modules/forum/forum.install \forum_schema()
  3. 10 core/modules/forum/forum.install \forum_schema()
  4. 11.x core/modules/forum/forum.install \forum_schema()

Implements hook_schema().

File

core/modules/forum/forum.install, line 63

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.