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

DROP CONSTRAINT: removes a constraint.

Mirrors AT_DropConstraint with missing_ok and behavior. Source: https://www.postgresql.org/docs/17/sql-altertable.html.

Dropping a constraintdoctest
$statement = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('ALTER TABLE t DROP CONSTRAINT IF EXISTS c RESTRICT');
    $statement->toString() // => 'ALTER TABLE t DROP CONSTRAINT IF EXISTS c RESTRICT'

Properties§

public Name $name
public bool $ifExists = false
public DropBehavior|null $behavior = null

Methods§

public function __construct(
    public Name $name,
    public bool $ifExists = false,
    public DropBehavior|null $behavior = null,
)

Parameters

$nameNameThe constraint
$ifExistsboolWhether IF EXISTS is written
$behaviorDropBehavior|nullCASCADE or RESTRICT, when written
public function deriveClause(Derivation $derivation, Environment $environment): void

Derives nothing: the constraint is a catalog name.

Parameters

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

Writes the action.

Parameters

$outOutput
Calls 2

Test cases 1§

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

Dedicated tests 1

Relations§

Instantiated in 2
Type checks 1