protected function Schema::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 Schema::constraintExists()

File

drupal/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php, line 441
Definition of Drupal\Core\Database\Driver\pgsql\Schema

Class

Schema

Namespace

Drupal\Core\Database\Driver\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();
}