You are here

protected function TaskStorageSchema::getEntitySchema in Search API 8

Gets the entity schema for the specified entity type.

Entity types may override this method in order to optimize the generated schema of the entity tables. However, only cross-field optimizations should be added here; e.g., an index spanning multiple fields. Optimizations that apply to a single field have to be added via SqlContentEntityStorageSchema::getSharedTableFieldSchema() instead.

Parameters

\Drupal\Core\Entity\ContentEntityTypeInterface $entity_type: The entity type definition.

bool $reset: (optional) If set to TRUE static cache will be ignored and a new schema array generation will be performed. Defaults to FALSE.

Return value

array A Schema API array describing the entity schema, excluding dedicated field tables.

Overrides SqlContentEntityStorageSchema::getEntitySchema

File

src/Entity/TaskStorageSchema.php, line 16

Class

TaskStorageSchema
Defines a storage schema for task entities.

Namespace

Drupal\search_api\Entity

Code

protected function getEntitySchema(ContentEntityTypeInterface $entity_type, $reset = FALSE) : array {
  $schema = parent::getEntitySchema($entity_type, $reset);
  if ($data_table = $this->storage
    ->getBaseTable()) {
    $data = 'data';

    // MySQL cannot handle UNIQUE indices on TEXT/BLOB fields without a prefix
    // length.
    if ($this->database
      ->driver() === 'mysql') {
      $data = [
        'data',
        255,
      ];
    }
    $schema[$data_table]['unique keys'] += [
      'task__unique' => [
        'type',
        'server_id',
        'index_id',
        $data,
      ],
    ];
  }
  return $schema;
}