protected function DatabaseSchema_pgsql::constraintExists

Helper function: check if a constraint (PK, FK, UK) exists.

Parameters

$table: The name of the table.

$name: The name of the constraint (typically 'pkey' or '[constraint]_key').

4 calls to DatabaseSchema_pgsql::constraintExists()
DatabaseSchema_pgsql::addPrimaryKey in drupal/includes/database/pgsql/schema.inc
Add a primary key.
DatabaseSchema_pgsql::addUniqueKey in drupal/includes/database/pgsql/schema.inc
Add a unique key.
DatabaseSchema_pgsql::dropPrimaryKey in drupal/includes/database/pgsql/schema.inc
Drop the primary key.
DatabaseSchema_pgsql::dropUniqueKey in drupal/includes/database/pgsql/schema.inc
Drop a unique key.

File

drupal/includes/database/pgsql/schema.inc, line 431
Database schema code for PostgreSQL database servers.

Class

DatabaseSchema_pgsql

Code

protected function constraintExists($table, $name) {
  $constraint_name = '{' . $table . '}_' . $name;
  return (bool) $this->connection
    ->query("SELECT 1 FROM pg_constraint WHERE conname = '{$constraint_name}'")
    ->fetchField();
}