function Schema::addUniqueKey

Add a unique key.

Parameters

string $table: The table to be altered.

string $name: The name of the key.

array $fields: An array of field names.

Throws

\Drupal\Core\Database\SchemaObjectDoesNotExistException If the specified table doesn't exist.

\Drupal\Core\Database\SchemaObjectExistsException If the specified table already has a key by that name.

4 methods override Schema::addUniqueKey()
Schema::addUniqueKey in core/modules/sqlite/src/Driver/Database/sqlite/Schema.php
Add a unique key.
Schema::addUniqueKey in core/modules/mysql/src/Driver/Database/mysql/Schema.php
Add a unique key.
Schema::addUniqueKey in core/modules/pgsql/src/Driver/Database/pgsql/Schema.php
Add a unique key.
StubSchema::addUniqueKey in core/tests/Drupal/Tests/Core/Database/Stub/StubSchema.php
Add a unique key.

File

core/lib/Drupal/Core/Database/Schema.php, line 446

Class

Schema
Provides a base implementation for Database Schema.

Namespace

Drupal\Core\Database

Code

abstract public function addUniqueKey($table, $name, $fields);

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.