You are here

protected function Schema::cleanUpPrimaryKey in Drupal driver for SQL Server and SQL Azure 8

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

Drop the primary key constraint.

Parameters

mixed $table:

5 calls to Schema::cleanUpPrimaryKey()
Schema::changeField in drivers/lib/Drupal/Driver/Database/sqlsrv/Schema.php
Override DatabaseSchema::changeField().
Schema::compressPrimaryKeyIndex in drivers/lib/Drupal/Driver/Database/sqlsrv/Schema.php
Sometimes the size of a table's primary key index needs to be reduced to allow for Primary XML Indexes.
Schema::dropFieldRelatedObjects in drivers/lib/Drupal/Driver/Database/sqlsrv/Schema.php
Drop the related objects of a column (indexes, constraints, etc.).
Schema::dropPrimaryKey in drivers/lib/Drupal/Driver/Database/sqlsrv/Schema.php
Override DatabaseSchema::dropPrimaryKey().
Schema::recreatePrimaryKey in drivers/lib/Drupal/Driver/Database/sqlsrv/Schema.php
Drops the current primary key and creates a new one. If the previous primary key was an internal primary key, it tries to cleant it up.

File

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

Class

Schema

Namespace

Drupal\Driver\Database\sqlsrv

Code

protected function cleanUpPrimaryKey($table) {

  // We are droping the constraint, but not the column.
  if ($existing_primary_key = $this
    ->primaryKeyName($table)) {
    $this->connection
      ->query("ALTER TABLE [{{$table}}] DROP CONSTRAINT {$existing_primary_key}");
  }

  // We are using computed columns to store primary keys,
  // try to remove it if it exists.
  if ($this
    ->fieldExists($table, $this->COMPUTED_PK_COLUMN_NAME)) {

    // The TCPK has compensation indexes that need to be cleared.
    $this
      ->dropIndex($table, $this->COMPUTED_PK_COLUMN_INDEX);
    $this
      ->dropField($table, $this->COMPUTED_PK_COLUMN_NAME);
  }

  // Try to get rid of the TPC
  $this
    ->cleanUpTechnicalPrimaryColumn($table);
}