classDropColumn
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.
$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 $columnpublic bool $ifExists = falsepublic DropBehavior|null $behavior = nullMethods§
public function __construct(
public Name $column,
public bool $ifExists = false,
public DropBehavior|null $behavior = null,
)Parameters
$column | Name | The column |
$ifExists | bool | Whether IF EXISTS is written |
$behavior | DropBehavior|null | CASCADE or RESTRICT, when written |
public function deriveClause(Derivation $derivation, Environment $environment): voidChecks that the column exists, unless IF EXISTS is written.
Parameters
$derivation | Derivation | |
$environment | Environment |
Calls 2
- method-call Alterations::column() line 50
- new Alterations line 50
public function render(Output $out): voidWrites DROP, the column and the behavior.
Parameters
$out | Output |
Calls 2
- method-call Output::keyword() line 59
- method-call Output::name() line 63
Test cases 2§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
DropColumnTestcalls
Other tests reaching this symbol 1
Relations§
Instantiated in 2
- new SqlSemantics\Platform\PostgreSql\Lowering\Table\AlterCommandRule::relation() packages/sql-semantics-postgres/src/Lowering/Table/AlterCommandRule.php:184
- new SqlSemantics\Platform\PostgreSql\Lowering\Table\AlterCommandRule::relation() packages/sql-semantics-postgres/src/Lowering/Table/AlterCommandRule.php:185