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.
\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.
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; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!Sql!SqlContentEntityStorageSchema.php/function/SqlContentEntityStorageSchema::addSharedTableFieldUniqueKey/8.1.x