protected function DatabaseSchema_pgsql::constraintExists
7.x schema.inc | protected DatabaseSchema_pgsql::constraintExists($table, $name) |
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-7.x/
includes/ database/ pgsql/ schema.inc - Add a primary key.
- DatabaseSchema_pgsql::addUniqueKey in drupal-7.x/
includes/ database/ pgsql/ schema.inc - Add a unique key.
- DatabaseSchema_pgsql::dropPrimaryKey in drupal-7.x/
includes/ database/ pgsql/ schema.inc - Drop the primary key.
- DatabaseSchema_pgsql::dropUniqueKey in drupal-7.x/
includes/ database/ pgsql/ schema.inc - Drop a unique key.
File
- drupal-7.x/
includes/ database/ pgsql/ schema.inc, line 431 - Database schema code for PostgreSQL database servers.
Class
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();
}