You are here

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

Add a primary column to the table.

Parameters

mixed $table: Table name.

2 calls to Schema::createTechnicalPrimaryColumn()
Schema::addUniqueKey in drivers/lib/Drupal/Driver/Database/sqlsrv/Schema.php
Add a unique key.
Schema::dropField in drivers/lib/Drupal/Driver/Database/sqlsrv/Schema.php
Should this be in a Transaction?

File

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

Class

Schema

Namespace

Drupal\Driver\Database\sqlsrv

Code

protected function createTechnicalPrimaryColumn($table) {
  if (!$this
    ->fieldExists($table, self::TECHNICAL_PK_COLUMN_NAME)) {
    $this->connection
      ->query("ALTER TABLE {{$table}} ADD " . self::TECHNICAL_PK_COLUMN_NAME . " UNIQUEIDENTIFIER DEFAULT NEWID() NOT NULL");
    $this
      ->resetColumnInformation($table);
  }
}