Helper function: check if a constraint (PK, FK, UK) exists.
$table: The name of the table.
$name: The name of the constraint (typically 'pkey' or '[constraint]_key').
protected function constraintExists($table, $name) {
$constraint_name = '{' . $table . '}_' . $name;
return (bool) $this->connection
->query("SELECT 1 FROM pg_constraint WHERE conname = '{$constraint_name}'")
->fetchField();
}