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

ADD [COLUMN] definition [FIRST | AFTER column]: a request to add one column.

Mirrors PT_alter_table_add_column. The expressions of the definition are derived in the scope of the changed table. The word COLUMN is optional and always written. Source: https://dev.mysql.com/doc/refman/8.4/en/alter-table.html#alter-table-add-drop-column.

Adding a column after the first onedoctest
$alter = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('ALTER TABLE t ADD b INT AFTER a');
    [$alter->statement->commands[0]->column->name->column->value, $alter->toString()] // => ['b', 'ALTER TABLE t ADD COLUMN b INT AFTER a']

Properties§

public ColumnPosition|null $position = null

Methods§

public function __construct(
    public ColumnDefinition $column,
    public ColumnPosition|null $position = null,
)

Parameters

$columnColumnDefinitionThe new column
$positionColumnPosition|nullWhere the column goes, when written
public function deriveCommand(Derivation $derivation, Environment $scope): void

Derives the expressions of the definition.

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