Index
Index
Represents a database index for migration actions.
class Index extends \Hazaar\DBI\Manager\Migration\Action\BaseActionExtends: Hazaar\DBI\Manager\Migration\Action\BaseAction
Encapsulates index attributes such as name, table, columns, uniqueness, index method, and an optional partial-index predicate. Provides methods for creating, altering, and dropping indexes in migration processes.
Properties
name
The name of the index.
public string $nameType: string
table
The name of the table the index applies to.
public string $tableType: string
columns
The columns included in the index.
public array $columnsType: array
unique
Whether the index is unique.
public bool $uniqueType: bool
using
The index method/algorithm (e.g., BTREE, HASH).
public string $usingType: string
where
A partial index predicate (the expression after WHERE), restricting the index to rows
public string $whereType: string
matching it instead of the whole table.
Methods
create
Creates the index in the database.
public create(Adapter $dbi, ?string $user): boolReturns: bool
Validates required properties and logs errors if missing.
Parameters
| Parameter | Type | Description |
|---|---|---|
$dbi | Hazaar\DBI\Adapter | the database adapter instance |
$user | string | not used for indexes, but included for consistency with other actions |
alter
Alters the index in the database.
public alter(Adapter $dbi): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$dbi | Hazaar\DBI\Adapter | the database adapter instance |
drop
Drops the index from the database.
public drop(Adapter $dbi): boolReturns: bool
Iterates over the drop list and attempts to drop each index.
Parameters
| Parameter | Type | Description |
|---|---|---|
$dbi | Hazaar\DBI\Adapter | the database adapter instance |
Generated by Hazaar API Doc Generator on Fri, 04 Sep 2026 23:32:16 +0000