mini\Table\ColumnDef class

Documentation

Column definition with type and optional index metadata

The type determines comparison semantics (whether to use collation). When a column is the leading column of an index, set $index to the index type and list any additional columns in $indexWith.

Examples:

// Simple text column, no index
new ColumnDef('name')

// Integer primary key
new ColumnDef('id', ColumnType::Int, IndexType::Primary)

// Indexed text column
new ColumnDef('email', ColumnType::Text, IndexType::Unique)

// Composite index on (org_id, user_id) - define on leading column
new ColumnDef('org_id', ColumnType::Int, IndexType::Index, [], 'user_id')

// DateTime column (sorts correctly with binary comparison)
new ColumnDef('created_at', ColumnType::DateTime)

// Decimal with fixed scale (2 decimal places)
new ColumnDef('price', ColumnType::Decimal, typeParameters: ['scale' => 2])

Properties (5)

public readonly array $indexWith
public readonly string $name
public readonly mini\Table\Types\ColumnType $type
public readonly mini\Table\Types\IndexType $index
public readonly array $typeParameters

Methods (6)

Documentation missing

Get type parameter with optional default

Get scale for Decimal columns (default: 0)

Get all columns in this index (including this column)

Check if this index can efficiently handle the given order columns

Get the common denominator ColumnDef

Source

src/Table/ColumnDef.php:36-170