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

DROP [COLUMN] c [RESTRICT | CASCADE], DROP PRIMARY KEY, DROP FOREIGN KEY, DROP INDEX, DROP CHECK or DROP CONSTRAINT.

Mirrors PT_alter_table_drop and its subclasses: one action with the kind of element. The primary key has no name; every other kind names its element (5.x lets a table qualify the name). RESTRICT and CASCADE are accepted only after a column and have no effect; they are kept as written. Only columns are part of a declaration context, so only a dropped column is checked (see AlterTable). The word COLUMN is optional and always written. Source: https://dev.mysql.com/doc/refman/8.4/en/alter-table.html.

Dropping a foreign keydoctest
$alter = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('ALTER TABLE t DROP FOREIGN KEY fk');
    [$alter->statement->commands[0]->kind, $alter->toString()] // => [\SqlSemantics\Platform\MySql\Statement\Alter\Command\ElementKind::ForeignKey, 'ALTER TABLE t DROP FOREIGN KEY fk']

Properties§

public ElementKind $kind
public ColumnName|null $name = null
public DropBehavior|null $behavior = null

Methods§

public function __construct(
    public ElementKind $kind,
    public ColumnName|null $name = null,
    public DropBehavior|null $behavior = null,
)

Parameters

$kindElementKindThe kind of element
$nameColumnName|nullThe element name; null only for the primary key
$behaviorDropBehavior|nullRESTRICT or CASCADE after a column, when written
Calls 3
public function deriveCommand(Derivation $derivation, Environment $scope): void

Derives nothing: the action holds no expression.

Parameters

$derivationDerivation
$scopeEnvironment
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 1
Type checks 1
Type declarations 1