You are here

protected function DatabaseSchema_sqlsrv::cleanUpTechnicalPrimaryColumn in Drupal driver for SQL Server and SQL Azure 7

Same name and namespace in other branches
  1. 7.3 sqlsrv/schema.inc \DatabaseSchema_sqlsrv::cleanUpTechnicalPrimaryColumn()
  2. 7.2 sqlsrv/schema.inc \DatabaseSchema_sqlsrv::cleanUpTechnicalPrimaryColumn()

Try to clean up the technical primary column if possible.

2 calls to DatabaseSchema_sqlsrv::cleanUpTechnicalPrimaryColumn()
DatabaseSchema_sqlsrv::addPrimaryKey in sqlsrv/schema.inc
Override DatabaseSchema::addPrimaryKey().
DatabaseSchema_sqlsrv::dropUniqueKey in sqlsrv/schema.inc
Override DatabaseSchema::dropUniqueKey().

File

sqlsrv/schema.inc, line 849
Database schema code for Microsoft SQL Server database servers.

Class

DatabaseSchema_sqlsrv

Code

protected function cleanUpTechnicalPrimaryColumn($table) {

  // Get the number of remaining unique indexes on the table, and prune
  // the technical primary column if possible.
  $unique_indexes = $this->connection
    ->query('SELECT COUNT(*) FROM sys.indexes WHERE object_id = OBJECT_ID(:table) AND is_unique = 1', array(
    ':table' => $this->connection
      ->prefixTables('{' . $table . '}'),
  ))
    ->fetchField();
  if (!$unique_indexes && !$this
    ->isTechnicalPrimaryKey($this
    ->primaryKeyName($table))) {
    $this
      ->dropField($table, '__pk');
  }
}