Constraint
Constraint
Represents a database constraint for migration actions.
class Constraint extends \Hazaar\DBI\Manager\Migration\Action\BaseActionExtends: Hazaar\DBI\Manager\Migration\Action\BaseAction
Encapsulates constraint attributes such as name, table, type, columns, and references. Provides methods for creating, altering, dropping, and serializing constraints in migration processes.
Properties
name
The name of the constraint.
public string $nameType: string
table
The name of the table the constraint applies to.
public string $tableType: string
type
The type of the constraint.
public ConstraintType $typeType: Hazaar\DBI\Manager\Migration\Enum\ConstraintType
column
The columns involved in the constraint.
public array $columnType: array
expression
The check expression, for CHECK constraints only.
public string $expressionType: string
match_option
The match option for foreign key constraints.
public string $match_optionType: string
update_rule
The action to take on update for foreign key constraints.
public string $update_ruleType: string
delete_rule
The action to take on delete for foreign key constraints.
public string $delete_ruleType: string
references
The reference information for foreign key constraints.
public ConstraintReference $referencesType: Hazaar\DBI\Manager\Migration\Action\Component\ConstraintReference
Methods
construct
Initializes the constraint from the provided data.
public construct(mixed $data): voidReturns: void
If the 'column' value is not an array, it is converted to an array.
Parameters
| Parameter | Type | Description |
|---|---|---|
$data | mixed | The data to initialize the constraint from. Modified by reference. |
create
Creates the constraint in the database.
public create(Adapter $dbi, ?string $user): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$dbi | Hazaar\DBI\Adapter | the database adapter instance |
$user | string | not used for constraints, included for interface consistency |
alter
Alters the constraint in the database.
public alter(Adapter $dbi): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$dbi | Hazaar\DBI\Adapter | the database adapter instance |
drop
Drops the constraint from the database.
public drop(Adapter $dbi): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$dbi | Hazaar\DBI\Adapter | the database adapter instance |
serializeDrop
Serializes the constraint for drop operations.
public serializeDrop(): mixedReturns: mixed
Generated by Hazaar API Doc Generator on Fri, 04 Sep 2026 23:32:16 +0000