protected SqlContentEntityStorageSchema::addSharedTableFieldUniqueKey(FieldStorageDefinitionInterface $storage_definition, &$schema)
Adds a unique key for the specified field to the given schema definition.
Also adds a 'not null' constraint, because many databases do not reliably support unique keys on null columns.
Parameters
\Drupal\Core\Field\FieldStorageDefinitionInterface $storage_definition: The storage definition of the field to which to add a unique key.
array $schema: A reference to the schema array to be updated.
File
- core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php, line 1671
Class
- SqlContentEntityStorageSchema
- Defines a schema handler that supports revisionable, translatable entities.
Namespace
Drupal\Core\Entity\Sql
Code
1 2 3 4 5 6 | protected function addSharedTableFieldUniqueKey(FieldStorageDefinitionInterface $storage_definition , & $schema ) { $name = $storage_definition ->getName(); $real_key = $this ->getFieldSchemaIdentifierName( $storage_definition ->getTargetEntityTypeId(), $name ); $schema [ 'unique keys' ][ $real_key ] = array ( $name ); $schema [ 'fields' ][ $name ][ 'not null' ] = TRUE; } |
Please login to continue.