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

ADD key or constraint: a request to add an index, a key, a foreign key or a check constraint.

Mirrors PT_alter_table_add_constraint. The expressions of the element (functional key parts, the check condition) are derived in the scope of the changed table. Source: https://dev.mysql.com/doc/refman/8.4/en/alter-table.html.

Adding an indexdoctest
$alter = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('ALTER TABLE t ADD INDEX i (a)');
    $alter->toString() // => 'ALTER TABLE t ADD INDEX i (a)'

Properties§

public TableElement $element

Methods§

public function __construct(public TableElement $element)

Parameters

$elementTableElementThe key or constraint
public function deriveCommand(Derivation $derivation, Environment $scope): void

Derives the expressions of the element.

Parameters

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

Writes the action.

Parameters

$outOutput
Calls 1

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