final class IndexConstraint
    implements Constraint
    uses Snapshot
Public API: explicitly declared with @visibility public.

A UNIQUE or PRIMARY KEY constraint built on an existing unique index: USING INDEX name.

Mirrors CONSTR_UNIQUE/CONSTR_PRIMARY with indexname. The key columns are those of the index, which a context does not declare; the server accepts this form only in ALTER TABLE ... ADD. Source: https://www.postgresql.org/docs/17/sql-altertable.html.

Reading a constraint on an existing indexdoctest
$alter = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('ALTER TABLE t ADD CONSTRAINT k PRIMARY KEY USING INDEX i');
    [$alter->statement->commands[0]->constraint->primary, $alter->statement->commands[0]->constraint->index->value] // => [true, 'i']

Properties§

public list<ConstraintAttribute> $attributes
public bool $primary
public Name $index
public Name|null $name = null

Methods§

public function __construct(
    public bool $primary,
    public Name $index,
    list<ConstraintAttribute> $attributes = [],
    public Name|null $name = null,
)

Parameters

$primaryboolWhether the constraint is a primary key; a unique constraint otherwise
$indexNameThe index
$attributeslist<ConstraintAttribute>The attributes in the order written
$nameName|nullThe constraint name
Calls 2
public function kind(): ConstraintKind

Answers the kind of the constraint.

Calls 2
public function deriveClause(Derivation $derivation, Environment $environment): void

Checks the attributes.

Parameters

$derivationDerivation
$environmentEnvironment
Calls 2
public function render(Output $out): void

Writes the constraint.

Parameters

$outOutput
Calls 4

Test cases 3§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 1
Other tests reaching this symbol 2

Relations§

Instantiated in 2
Constant reads 1
Type checks 3