You are here

protected function Database::removeFieldStorage in Search API 8

Drops a field's table and its column from the denormalized table.

Parameters

string $name: The field name.

array $field: Backend-internal information about the field.

string $index_table: The table which stores the denormalized data for this field.

1 call to Database::removeFieldStorage()
Database::fieldsUpdated in modules/search_api_db/src/Plugin/search_api/backend/Database.php
Updates the storage tables when the field configuration changes.

File

modules/search_api_db/src/Plugin/search_api/backend/Database.php, line 1137

Class

Database
Indexes and searches items using the database.

Namespace

Drupal\search_api_db\Plugin\search_api\backend

Code

protected function removeFieldStorage($name, array $field, $index_table) {
  if ($this
    ->getDataTypeHelper()
    ->isTextType($field['type'])) {

    // Remove data from the text table.
    $this->database
      ->delete($field['table'])
      ->condition('field_name', static::getTextFieldName($name))
      ->execute();
  }
  elseif ($this->database
    ->schema()
    ->tableExists($field['table'])) {

    // Remove the field table.
    $this->database
      ->schema()
      ->dropTable($field['table']);
  }

  // Remove the field column from the denormalized table.
  $this->database
    ->schema()
    ->dropField($index_table, $field['column']);
}