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 if ($data_table = $this->storage->getDataTable()) {
21 $schema[$data_table]['indexes'] += [
22 'node__frontpage' => ['promote', 'status', 'sticky', 'created'],
23 'node__title_type' => ['title', ['type', 4]],
33 protected function getSharedTableFieldSchema(FieldStorageDefinitionInterface $storage_definition, $table_name, array $column_mapping) {
34 $schema = parent::getSharedTableFieldSchema($storage_definition, $table_name, $column_mapping);
35 $field_name = $storage_definition->getName();
37 if ($table_name == 'node_revision') {
38 switch ($field_name) {
40 $this->addSharedTableFieldIndex($storage_definition, $schema, TRUE);
44 $this->addSharedTableFieldForeignKey($storage_definition, $schema, 'users', 'uid');
49 if ($table_name == 'node_field_data') {
50 switch ($field_name) {
55 // Improves the performance of the indexes defined
56 // in getEntitySchema().
57 $schema['fields'][$field_name]['not null'] = TRUE;
62 // @todo Revisit index definitions:
63 // https://www.drupal.org/node/2015277.
64 $this->addSharedTableFieldIndex($storage_definition, $schema, TRUE);