db_add_unique_key

Versions
6
db_add_unique_key(&$ret, $table, $name, $fields)
7
db_add_unique_key($table, $name, $fields)

Add a unique key.

Parameters

$ret Array to which query results will be added.

$table The table to be altered.

$name The name of the key.

$fields An array of field names.

Related topics

▾ 5 functions call db_add_unique_key()

system_update_6019 in modules/system/system.install
Reconcile small differences in the previous, manually created mysql and pgsql schemas so they are the same and can be represented by a single schema structure.
system_update_6032 in modules/system/system.install
profile_fields.name used to be nullable but is part of a unique key and so shouldn't be.
system_update_6036 in modules/system/system.install
Change the search schema and indexing.
system_update_6043 in modules/system/system.install
Update table indices to make them more rational and useful.
_db_create_keys in includes/database.pgsql.inc

Code

includes/database.pgsql.inc, line 793

<?php
function db_add_unique_key(&$ret, $table, $name, $fields) {
  $name = '{'. $table .'}_'. $name .'_key';
  $ret[] = update_sql('ALTER TABLE {'. $table .'} ADD CONSTRAINT '.
    $name .' UNIQUE ('. implode(',', $fields) .')');
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.