You are here

public function DatabaseSchema_sqlsrv::addIndex 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::addIndex()
  2. 7.2 sqlsrv/schema.inc \DatabaseSchema_sqlsrv::addIndex()

Override DatabaseSchema::addIndex().

@status tested

Overrides DatabaseSchema::addIndex

1 call to DatabaseSchema_sqlsrv::addIndex()
DatabaseSchema_sqlsrv::recreateTableKeys in sqlsrv/schema.inc
Re-create keys associated to a table.

File

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

Class

DatabaseSchema_sqlsrv

Code

public function addIndex($table, $name, $fields) {
  if (!$this
    ->tableExists($table)) {
    throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add index %name to table %table: table doesn't exist.", array(
      '%table' => $table,
      '%name' => $name,
    )));
  }
  if ($this
    ->indexExists($table, $name)) {
    throw new DatabaseSchemaObjectExistsException(t("Cannot add index %name to table %table: index already exists.", array(
      '%table' => $table,
      '%name' => $name,
    )));
  }
  $this->connection
    ->query($this
    ->createIndexSql($table, $name, $fields));
}