You are here

public function Schema::dropUniqueKey in Drupal driver for SQL Server and SQL Azure 3.0.x

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

Drop a unique key.

Parameters

$table: The table to be altered.

$name: The name of the key.

Return value

TRUE if the key was successfully dropped, FALSE if there was no key by that name to begin with.

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 508

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}}");
  $this->connection
    ->query("ALTER TABLE {{$table}} DROP COLUMN __unique_{$name}");
  $this
    ->resetColumnInformation($table);

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