You are here

public function Table::dropIndex in Data 8

Drop an index from a table.

Throws

DataException

2 calls to Table::dropIndex()
Table::changeField in src/Table.php
Change a field.
Table::changeIndex in src/Table.php
Change indexes of a table.

File

src/Table.php, line 311

Class

Table
Manages data access and manipulation for a single data table. Use data_create_table() or data_get_table() to instantiate an object from this class.

Namespace

Drupal\data

Code

public function dropIndex($field) {
  $success = \Drupal::database()
    ->schema()
    ->dropIndex($this->name, $field);
  if ($success) {
    $schema = $this->table_schema;
    unset($schema['indexes'][$field]);
    $this
      ->update(array(
      'table_schema' => $schema,
    ));
    drupal_get_schema($this->name, TRUE);
    return;
  }
  throw new DataException(t('Error dropping index.'));
}