You are here

protected function Schema::cleanUpPrimaryKey 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::cleanUpPrimaryKey()
  2. 8 drivers/lib/Drupal/Driver/Database/sqlsrv/Schema.php \Drupal\Driver\Database\sqlsrv\Schema::cleanUpPrimaryKey()

Drop the primary key constraint.

Parameters

mixed $table: Table name.

7 calls to Schema::cleanUpPrimaryKey()
Schema::addField in drivers/lib/Drupal/Driver/Database/sqlsrv/Schema.php
Add a new field to a table.
Schema::changeField in drivers/lib/Drupal/Driver/Database/sqlsrv/Schema.php
Change a field definition.
Schema::compressPrimaryKeyIndex in drivers/lib/Drupal/Driver/Database/sqlsrv/Schema.php
Compress Primary key Index.
Schema::dropField in drivers/lib/Drupal/Driver/Database/sqlsrv/Schema.php
Should this be in a Transaction?
Schema::dropFieldRelatedObjects in drivers/lib/Drupal/Driver/Database/sqlsrv/Schema.php
Drop the related objects of a column (indexes, constraints, etc.).

... See full list

File

drivers/lib/Drupal/Driver/Database/sqlsrv/Schema.php, line 1921

Class

Schema

Namespace

Drupal\Driver\Database\sqlsrv

Code

protected function cleanUpPrimaryKey($table) {

  // We are droping the constraint, but not the column.
  $existing_primary_key = $this
    ->primaryKeyName($table);
  if ($existing_primary_key !== FALSE) {
    $this
      ->dropConstraint($table, $existing_primary_key, FALSE);
  }

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

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

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