Adds a primary key to a database table.
$table: Name of the table to be altered.
$fields: Array of fields for the primary key.
function db_add_primary_key($table, $fields) {
return Database::getConnection()
->schema()
->addPrimaryKey($table, $fields);
}