5 use Drupal\Core\Entity\ContentEntityTypeInterface;
6 use Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema;
7 use Drupal\Core\Field\FieldStorageDefinitionInterface;
10 * Defines the node schema handler.
12 class NodeStorageSchema extends SqlContentEntityStorageSchema {
17 protected function getEntitySchema(ContentEntityTypeInterface $entity_type, $reset = FALSE) {
18 $schema = parent::getEntitySchema($entity_type, $reset);
20 $schema['node_field_data']['indexes'] += [
21 'node__frontpage' => ['promote', 'status', 'sticky', 'created'],
22 'node__title_type' => ['title', ['type', 4]],
31 protected function getSharedTableFieldSchema(FieldStorageDefinitionInterface $storage_definition, $table_name, array $column_mapping) {
32 $schema = parent::getSharedTableFieldSchema($storage_definition, $table_name, $column_mapping);
33 $field_name = $storage_definition->getName();
35 if ($table_name == 'node_revision') {
36 switch ($field_name) {
38 $this->addSharedTableFieldIndex($storage_definition, $schema, TRUE);
42 $this->addSharedTableFieldForeignKey($storage_definition, $schema, 'users', 'uid');
47 if ($table_name == 'node_field_data') {
48 switch ($field_name) {
53 // Improves the performance of the indexes defined
54 // in getEntitySchema().
55 $schema['fields'][$field_name]['not null'] = TRUE;
60 // @todo Revisit index definitions:
61 // https://www.drupal.org/node/2015277.
62 $this->addSharedTableFieldIndex($storage_definition, $schema, TRUE);