You are here

protected function SqlContentEntityStorageSchema::addSharedTableFieldIndex in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema::addSharedTableFieldIndex()
  2. 9 core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema::addSharedTableFieldIndex()

Adds an index for the specified field to the given schema definition.

Parameters

\Drupal\Core\Field\FieldStorageDefinitionInterface $storage_definition: The storage definition of the field for which an index should be added.

array $schema: A reference to the schema array to be updated.

bool $not_null: (optional) Whether to also add a 'not null' constraint to the column being indexed. Doing so improves index performance. Defaults to FALSE, in case the field needs to support NULL values.

int $size: (optional) The index size. Defaults to no limit.

7 calls to SqlContentEntityStorageSchema::addSharedTableFieldIndex()
CommentStorageSchema::getSharedTableFieldSchema in core/modules/comment/src/CommentStorageSchema.php
Gets the schema for a single field definition.
EntityTestUpdateStorageSchema::getSharedTableFieldSchema in core/modules/system/tests/modules/entity_test_update/src/EntityTestUpdateStorageSchema.php
Gets the schema for a single field definition.
FileStorageSchema::getSharedTableFieldSchema in core/modules/file/src/FileStorageSchema.php
Gets the schema for a single field definition.
MenuLinkContentStorageSchema::getSharedTableFieldSchema in core/modules/menu_link_content/src/MenuLinkContentStorageSchema.php
Gets the schema for a single field definition.
NodeStorageSchema::getSharedTableFieldSchema in core/modules/node/src/NodeStorageSchema.php
Gets the schema for a single field definition.

... See full list

File

core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php, line 2167

Class

SqlContentEntityStorageSchema
Defines a schema handler that supports revisionable, translatable entities.

Namespace

Drupal\Core\Entity\Sql

Code

protected function addSharedTableFieldIndex(FieldStorageDefinitionInterface $storage_definition, &$schema, $not_null = FALSE, $size = NULL) {
  $name = $storage_definition
    ->getName();
  $real_key = $this
    ->getFieldSchemaIdentifierName($storage_definition
    ->getTargetEntityTypeId(), $name);
  $schema['indexes'][$real_key] = [
    $size ? [
      $name,
      $size,
    ] : $name,
  ];
  if ($not_null) {
    $schema['fields'][$name]['not null'] = TRUE;
  }
}