final class AddConstraint
    implements AlterCommand
    uses Snapshot
Public API: explicitly declared with @visibility public.

ADD table_constraint: adds a constraint.

Mirrors AT_AddConstraint. The constraint is derived where the relation is visible. Source: https://www.postgresql.org/docs/17/sql-altertable.html.

Adding a constraintdoctest
$statement = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('ALTER TABLE t ADD CONSTRAINT c CHECK (a > 0) NOT VALID');
    $statement->toString() // => 'ALTER TABLE t ADD CONSTRAINT c CHECK (a > 0) NOT VALID'

Properties§

public Constraint $constraint

Methods§

public function __construct(public Constraint $constraint)

Parameters

$constraintConstraintThe constraint
Calls 3
public function deriveClause(Derivation $derivation, Environment $environment): void

Derives the constraint against the relation.

Parameters

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

Writes ADD and the constraint.

Parameters

$outOutput
Calls 1

Test cases 2§

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 1

Relations§

Instantiated in 1
Type checks 3