You are here

public function TableComparison::getDeclaredIndexes in Schema 8

Get all declared indexes for this table.

Parameters

bool $include_extra: Also include extra indexes, i.e. indexes which are present in the database but missing from the declared schema.

Return value

array

File

src/Comparison/Result/TableComparison.php, line 154
Contains Drupal\schema\Comparison\Result\TableComparison.

Class

TableComparison

Namespace

Drupal\schema\Comparison\Result

Code

public function getDeclaredIndexes($include_extra = FALSE) {
  $indexes = array(
    'indexes' => isset($this->schema['indexes']) ? $this->schema['indexes'] : array(),
    'unique keys' => isset($this->schema['unique keys']) ? $this->schema['unique keys'] : array(),
  );
  if ($include_extra) {

    /** @var ExtraIndex $index */
    foreach ($this
      ->getExtraIndexes() as $index) {
      $type = $index
        ->getType() == 'UNIQUE' ? 'unique keys' : 'indexes';
      $indexes[$type][$index
        ->getIndexName()] = $index
        ->getSchema();
    }
  }
  return $indexes;
}