You are here

public function Schema::dropUniqueKey in Drupal driver for SQL Server and SQL Azure 8.2

Same name and namespace in other branches
  1. 8 drivers/lib/Drupal/Driver/Database/sqlsrv/Schema.php \Drupal\Driver\Database\sqlsrv\Schema::dropUniqueKey()
  2. 3.0.x drivers/lib/Drupal/Driver/Database/sqlsrv/Schema.php \Drupal\Driver\Database\sqlsrv\Schema::dropUniqueKey()

Override DatabaseSchema::dropUniqueKey().

Overrides Schema::dropUniqueKey

1 call to Schema::dropUniqueKey()
Schema::dropFieldRelatedObjects in drivers/lib/Drupal/Driver/Database/sqlsrv/Schema.php
Drop the related objects of a column (indexes, constraints, etc.).

File

drivers/lib/Drupal/Driver/Database/sqlsrv/Schema.php, line 1263
Definition of Drupal\Driver\Database\sqlsrv\Schema

Class

Schema

Namespace

Drupal\Driver\Database\sqlsrv

Code

public function dropUniqueKey($table, $name) {
  if (!$this
    ->uniqueKeyExists($table, $name)) {
    return false;
  }
  $this->connection
    ->query("DROP INDEX {$name}_unique ON [{{$table}}]");

  // Some unique keys do not have an emulated unique column.
  if ($this->connection
    ->Scheme()
    ->FieldExists($table, "__unique_{$name}")) {
    $this->connection
      ->query("ALTER TABLE [{{$table}}] DROP COLUMN __unique_{$name}");
  }

  // Try to clean-up the technical primary key if possible.
  $this
    ->cleanUpTechnicalPrimaryColumn($table);
  return true;
}