Version
Version
Properties
comment
public string $comment
source
protected array $source
number
protected int $number
valid
protected bool $valid = true
migrate
protected Event $migrate
Methods
__toString
public __toString(): void
loadFromFile
public loadFromFile(string $filename): ?self
Parameters
Parameter | Type | Description |
---|---|---|
$filename | string |
create
public create(): self
getSourceFile
Retrieves the full path of the source file.
public getSourceFile(): string
This method constructs the full path of the source file by concatenating the directory name and the base name of the source file, separated by the directory separator.
loadMigration
Retrieves the migration script from the source file.
public loadMigration(): ?Migration
This method reads the content of the source file, decodes it from JSON format, and returns it as a \stdClass object. If the JSON content is invalid, an exception is thrown.
replay
Replays the migration for the current version.
public replay(Adapter $dbi, string $schemaVersionTable): bool
This method loads the migration, begins a database transaction, and attempts to replay the migration. If the migration is successfully replayed, it updates the schema version in the database. If any exception occurs during the process, the transaction is canceled and the exception is rethrown.
Parameters
Parameter | Type | Description |
---|---|---|
$dbi | Adapter | the database adapter instance |
$schemaVersionTable | string |
rollback
Rollbacks the current migration version.
public rollback(Adapter $dbi, string $schemaVersionTable): bool
This method attempts to rollback the current migration version by running the down
method of the migration. If the rollback is successful, the version number is removed from the schema_version
table. If the rollback fails, an exception is thrown and the transaction is cancelled.
Parameters
Parameter | Type | Description |
---|---|---|
$dbi | Adapter | the database adapter instance |
$schemaVersionTable | string |
unlink
Unlinks (deletes) the source file associated with this object.
public unlink(): bool
generateVersionNumber
public generateVersionNumber(): string
constructed
protected constructed(): void
loadMigrationEventFunctions
Loads migration event functions from the specified event.
private loadMigrationEventFunctions(Event $event): void
This method iterates through the actions of the given event and checks if the action type is either a function or a trigger. If the action type is not a function or trigger, or if the action specification content is already set, it continues to the next action.
For each action that requires loading content, it constructs the file path to the SQL file containing the function definition. If the file exists, it reads the content of the file and assigns it to the action specification content.
Parameters
Parameter | Type | Description |
---|---|---|
$event | Event | the event containing actions to be processed |
Generated by Hazaar API Doc Generator