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

ALTER [ COLUMN ] ... ADD GENERATED ... AS IDENTITY: makes a column an identity column.

Mirrors AT_AddIdentity with the sequence options. The column must exist, and its declared type is checked by PG-IDENTITY-TYPE-001. Source: https://www.postgresql.org/docs/17/sql-altertable.html.

Adding an identitydoctest
$statement = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('ALTER TABLE t ALTER a ADD GENERATED ALWAYS AS IDENTITY (CACHE 10)');
    $statement->toString() // => 'ALTER TABLE t ALTER a ADD GENERATED ALWAYS AS IDENTITY (CACHE 10)'

Properties§

public list<SequenceOption> $options
public Name $column

Methods§

public function __construct(
    public Name $column,
    public GeneratedWhen $when,
    list<SequenceOption> $options = [],
)

Parameters

$columnNameThe column
$whenGeneratedWhenWhen the column takes a generated value
$optionslist<SequenceOption>The options of the sequence; none means no parentheses are written
Calls 2
public function deriveClause(Derivation $derivation, Environment $environment): void

Checks that the column exists and has an identity type, and derives the options.

Parameters

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

Writes the action.

Parameters

$outOutput
Calls 5

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 2