Schema
Schema
Represents a database schema, including tables, views, constraints, indexes, functions, triggers, and extensions.
class Schema extends \Hazaar\Model\StructExtends: Hazaar\Model\Struct
Provides methods for importing, applying migrations, and converting to migration objects.
Properties
extensions
public array $extensionsType: array
types
public array $typesType: array
tables
public array $tablesType: array
views
public array $viewsType: array
constraints
public array $constraintsType: array
indexes
public array $indexesType: array
functions
public array $functionsType: array
triggers
public array $triggersType: array
ignoreTables
private array $ignoreTables = array (
0 => 'schema_version',
1 => '__hz_file',
2 => '__hz_file_chunk',
)Type: array
Methods
load
Load a schema from an array of versions.
public load(array $versions): selfReturns: self
Parameters
| Parameter | Type | Description |
|---|---|---|
$versions | array |
import
Imports the current database schema using the provided adapter.
public import(Adapter $dbi): selfReturns: self
Gathers extensions, tables, constraints, indexes, functions, triggers, and views from the database.
Parameters
| Parameter | Type | Description |
|---|---|---|
$dbi | Hazaar\DBI\Adapter | the database adapter instance |
applyVersion
Applies a migration version to the schema, updating its state.
public applyVersion(Version $version): voidReturns: void
Processes all actions in the version's 'up' event and applies them to the schema.
Parameters
| Parameter | Type | Description |
|---|---|---|
$version | Hazaar\DBI\Manager\Version | the migration version to apply |
toMigration
Converts the schema to a Migration object representing the current state.
public toMigration(): MigrationReturns: Hazaar\DBI\Manager\Migration
Generates a migration with all extensions, tables, views, constraints, indexes, functions, and triggers.
findActionOrComponent
public findActionOrComponent(string $name, array $haystack): Action|BaseAction|BaseComponent|nullReturns: Hazaar\DBI\Manager\Migration\Action|Hazaar\DBI\Manager\Migration\Action\BaseAction|Hazaar\DBI\Manager\Migration\Action\Component\BaseComponent|null
Parameters
| Parameter | Type | Description |
|---|---|---|
$name | string | |
$haystack | array |
create
Creates a new element in the schema.
private create(Action $action): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$action | Hazaar\DBI\Manager\Migration\Action | the action containing the specifications for the element to be created |
alter
Alters an existing element in the schema based on the provided action.
private alter(Action $action): voidReturns: void
Updates the element with the new specification from the action.
Parameters
| Parameter | Type | Description |
|---|---|---|
$action | Hazaar\DBI\Manager\Migration\Action | the action containing the type and specifications for the element to alter |
drop
Drops an element based on the provided action.
private drop(Action $action): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$action | Hazaar\DBI\Manager\Migration\Action | the action containing the type and specifications for the element to drop |
dropTableReferences
Drops all constraints or indexes that reference the specified table.
private dropTableReferences(array $elements, string $table): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$elements | array | the array of constraints or indexes to search for references |
$table | string |
getElementName
Get the name of the element based on the action type.
private getElementName(ActionType $type): stringReturns: string
Parameters
| Parameter | Type | Description |
|---|---|---|
$type | Hazaar\DBI\Manager\Migration\Enum\ActionType | the type of action to get the element name for |
Generated by Hazaar API Doc Generator on Fri, 04 Sep 2026 23:32:16 +0000