Newer
Older
<?php
/**
* @file
* Contains \Drupal\comment\CommentStorageSchema.
*/
namespace Drupal\comment;
use Drupal\Core\Entity\ContentEntityTypeInterface;
catch
committed
use Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema;
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/**
* Defines the comment schema handler.
*/
class CommentStorageSchema extends SqlContentEntityStorageSchema {
/**
* {@inheritdoc}
*/
protected function getEntitySchema(ContentEntityTypeInterface $entity_type, $reset = FALSE) {
$schema = parent::getEntitySchema($entity_type, $reset);
// Marking the respective fields as NOT NULL makes the indexes more
// performant.
$schema['comment_field_data']['fields']['created']['not null'] = TRUE;
$schema['comment_field_data']['fields']['thread']['not null'] = TRUE;
unset($schema['comment_field_data']['indexes']['comment_field__pid__target_id']);
unset($schema['comment_field_data']['indexes']['comment_field__entity_id__target_id']);
$schema['comment_field_data']['indexes'] += array(
'comment__status_pid' => array('pid', 'status'),
'comment__num_new' => array(
'entity_id',
'entity_type',
'comment_type',
'status',
'created',
'cid',
'thread',
),
'comment__entity_langcode' => array(
'entity_id',
'entity_type',
'comment_type',
'default_langcode',
),
'comment__created' => array('created'),
);
$schema['comment_field_data']['foreign keys'] += array(
'comment__author' => array(
'table' => 'users',
'columns' => array('uid' => 'uid'),
),
);
return $schema;
}
}