BaseAction
BaseAction
Abstract base class for migration actions.
class BaseAction extends \Hazaar\Model\Struct implements \Hazaar\DBI\Manager\Migration\Interface\SpecExtends: Hazaar\Model\Struct
Implements: Hazaar\DBI\Manager\Migration\Interface\Spec
Provides a framework for implementing database migration actions such as create, alter, and drop. Subclasses should override the action methods to provide specific logic for each migration step. Implements the Spec interface for migration specifications.
Properties
drop
public array $dropType: array
Methods
construct
Initializes the action from the provided data.
public construct(mixed $data): voidReturns: void
If the data does not contain 'name' or 'drop' and is not an associative array, it is treated as a drop list.
Parameters
| Parameter | Type | Description |
|---|---|---|
$data | mixed | The data to initialize the action from. Modified by reference. |
run
Executes the migration action based on the specified type and name.
public run(Adapter $dbi, ActionType $type, ActionName $name, ?string $user): boolReturns: bool
Dispatches to the appropriate method (create, alter, drop) depending on the action name.
Parameters
| Parameter | Type | Description |
|---|---|---|
$dbi | Hazaar\DBI\Adapter | the database adapter instance |
$type | Hazaar\DBI\Manager\Migration\Enum\ActionType | the type of migration action |
$name | Hazaar\DBI\Manager\Migration\Enum\ActionName | the name of the migration action (CREATE, ALTER, DROP) |
$user | string |
create
Performs the CREATE migration action.
public create(Adapter $dbi, ?string $user): boolReturns: bool
Override in subclasses to implement creation logic for the database object.
Parameters
| Parameter | Type | Description |
|---|---|---|
$dbi | Hazaar\DBI\Adapter | the database adapter instance |
$user | string | the database user to perform the action as, if applicable |
alter
Performs the ALTER migration action.
public alter(Adapter $dbi): boolReturns: bool
Override in subclasses to implement alteration logic for the database object.
Parameters
| Parameter | Type | Description |
|---|---|---|
$dbi | Hazaar\DBI\Adapter | the database adapter instance |
drop
Performs the DROP migration action.
public drop(Adapter $dbi): boolReturns: bool
Override in subclasses to implement drop logic for the database object.
Parameters
| Parameter | Type | Description |
|---|---|---|
$dbi | Hazaar\DBI\Adapter | the database adapter instance |
apply
Apply an ALTER action to the BaseAction.
public apply(self $action): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$action | self |
diff
Find the difference between two BaseActions.
public diff(self $action): ?selfReturns: self
Parameters
| Parameter | Type | Description |
|---|---|---|
$action | self |
serializeDrop
Return the BaseAction as an array.
public serializeDrop(): mixedReturns: mixed
Generated by Hazaar API Doc Generator on Fri, 04 Sep 2026 23:32:16 +0000