SqlContentEntityStorageSchema::addSharedTableFieldIndex

protected SqlContentEntityStorageSchema::addSharedTableFieldIndex(FieldStorageDefinitionInterface $storage_definition, &$schema, $not_null = FALSE, $size = NULL)

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.

File

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

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] = array($size ? array($name, $size) : $name);
  if ($not_null) {
    $schema['fields'][$name]['not null'] = TRUE;
  }
}
doc_Drupal
2016-10-29 09:43:34
Comments
Leave a Comment

Please login to continue.