Primordyx Framework Documentation

MigrationGenerator
in package

Table of Contents

Properties

$dryRun  : bool
$migrationName  : string|null
$migrationsPath  : string|null
$migrationType  : string|null
$targetDatabase  : string
$templatesPath  : string
$templateVariables  : array<string|int, mixed>

Methods

__construct()  : mixed
MigrationGenerator constructor.
dryRun()  : static
Enable or disable dry run mode with method chaining.
generate()  : array<string|int, mixed>
Generate migration files.
getAvailableTypes()  : array<string|int, mixed>
Get list of available migration types based on template files.
migrationName()  : static
Set the migration name with method chaining.
migrationsPath()  : static
Set the migrations directory path with method chaining.
migrationType()  : static
Set the migration type with method chaining.
targetDatabase()  : static
Set the target database name with method chaining.
templateVariables()  : static
Set template variables for placeholder replacement with method chaining.
extractTableName()  : string
Extract likely table name from migration name.
loadAndProcessTemplate()  : string
Load template file and process placeholders.
validateGeneration()  : void
Validate that all required properties are set for generation.

Properties

Methods

__construct()

MigrationGenerator constructor.

public __construct(string $templatesPath) : mixed
Parameters
$templatesPath : string

Path to migration templates directory

Tags
throws
RuntimeException

If templates path does not exist

dryRun()

Enable or disable dry run mode with method chaining.

public dryRun([bool $enable = true ]) : static
Parameters
$enable : bool = true

Set to true to enable dry run mode, false to disable

Return values
static

Returns self for method chaining

generate()

Generate migration files.

public generate() : array<string|int, mixed>
Tags
throws
RuntimeException

If required properties are not set

throws
RuntimeException

If migrations directory cannot be created

throws
RuntimeException

If template files don't exist

throws
RuntimeException

If migration files already exist

Return values
array<string|int, mixed>

Generated file paths ['up' => path, 'down' => path]

getAvailableTypes()

Get list of available migration types based on template files.

public getAvailableTypes() : array<string|int, mixed>
Return values
array<string|int, mixed>

List of available migration types

migrationName()

Set the migration name with method chaining.

public migrationName(string $name) : static
Parameters
$name : string

Migration name

Return values
static

Returns self for method chaining

migrationsPath()

Set the migrations directory path with method chaining.

public migrationsPath(string $path) : static
Parameters
$path : string

Absolute path to migrations directory.

Tags
throws
InvalidArgumentException

If path is empty

throws
RuntimeException

If path does not exist or is not readable

Return values
static

Returns self for method chaining

migrationType()

Set the migration type with method chaining.

public migrationType(string $type) : static
Parameters
$type : string

Migration type

Return values
static

Returns self for method chaining

targetDatabase()

Set the target database name with method chaining.

public targetDatabase(string $databaseName) : static
Parameters
$databaseName : string

Target database name

Return values
static

Returns self for method chaining

templateVariables()

Set template variables for placeholder replacement with method chaining.

public templateVariables(array<string|int, mixed> $variables) : static
Parameters
$variables : array<string|int, mixed>

Template variables

Return values
static

Returns self for method chaining

extractTableName()

Extract likely table name from migration name.

private extractTableName(string $migrationName) : string
Parameters
$migrationName : string

Migration name

Return values
string

Extracted table name

loadAndProcessTemplate()

Load template file and process placeholders.

private loadAndProcessTemplate(string $templateFile) : string
Parameters
$templateFile : string

Template filename

Tags
throws
RuntimeException

If template file doesn't exist

Return values
string

Processed template content

validateGeneration()

Validate that all required properties are set for generation.

private validateGeneration() : void
Tags
throws
RuntimeException

If validation fails


        
On this page

Search results