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

DROP [ COLUMN ]: removes a column.

Mirrors AT_DropColumn with missing_ok and behavior. The column must exist unless IF EXISTS is written. Source: https://www.postgresql.org/docs/17/sql-altertable.html.

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

Properties§

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

Methods§

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

Parameters

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

Checks that the column exists, unless IF EXISTS is written.

Parameters

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

Writes DROP, the column and the behavior.

Parameters

$outOutput
Calls 2

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 2
Type checks 1