function db_add_primary_key

Adds a primary key to a database table.

Parameters

$table: Name of the table to be altered.

$fields: Array of fields for the primary key.

Related topics

4 calls to db_add_primary_key()
field_sql_storage_update_8000 in drupal/core/modules/field_sql_storage/field_sql_storage.install
Renames the 'language' column to 'langcode' in field data tables.
locale_update_8005 in drupal/core/modules/locale/locale.install
Update plural interface translations to new format.
node_update_8015 in drupal/core/modules/node/node.install
Add language support to the {node_access} table.
search_update_8001 in drupal/core/modules/search/search.install
Adds the langcode field and indexes to {search_dataset} and {search_index}.

File

drupal/core/includes/database.inc, line 763
Core systems for the database layer.

Code

function db_add_primary_key($table, $fields) {
  return Database::getConnection()
    ->schema()
    ->addPrimaryKey($table, $fields);
}