Constants

DATE_FORMAT

DATE_FORMAT = 'YmdHis' : string

MIGRATION_FILE_NAME_PATTERN

MIGRATION_FILE_NAME_PATTERN = '/^\d+_([\w_]+).php$/i' : string

SEED_FILE_NAME_PATTERN

SEED_FILE_NAME_PATTERN = '/^([A-Z][a-z0-9]+).php$/i' : string

Methods

getCurrentTimestamp()

getCurrentTimestamp() : string

Gets the current timestamp string, in UTC.

Returns

string

getExistingMigrationClassNames()

getExistingMigrationClassNames(  $path) : string

Gets an array of all the existing migration class names.

Parameters

$path

Returns

string

getVersionFromFileName()

getVersionFromFileName(string  $fileName) : string

Get the version from the beginning of a file name.

Parameters

string $fileName

File Name

Returns

string

mapClassNameToFileName()

mapClassNameToFileName(string  $className) : string

Turn migration names like 'CreateUserTable' into file names like '12345678901234_create_user_table.php' or 'LimitResourceNamesTo30Chars' into '12345678901234_limit_resource_names_to_30_chars.php'.

Parameters

string $className

Class Name

Returns

string

mapFileNameToClassName()

mapFileNameToClassName(string  $fileName) : string

Turn file names like '12345678901234_create_user_table.php' into class names like 'CreateUserTable'.

Parameters

string $fileName

File Name

Returns

string

isUniqueMigrationClassName()

isUniqueMigrationClassName(string  $className, string  $path) : boolean

Check if a migration class name is unique regardless of the timestamp.

This method takes a class name and a path to a migrations directory.

Migration class names must be in CamelCase format. e.g: CreateUserTable or AddIndexToPostsTable.

Single words are not allowed on their own.

Parameters

string $className

Class Name

string $path

Path

Returns

boolean

isValidPhinxClassName()

isValidPhinxClassName(string  $className) : boolean

Check if a migration/seed class name is valid.

Migration & Seed class names must be in CamelCase format. e.g: CreateUserTable, AddIndexToPostsTable or UserSeeder.

Single words are not allowed on their own.

Parameters

string $className

Class Name

Returns

boolean

isValidMigrationFileName()

isValidMigrationFileName(string  $fileName) : boolean

Check if a migration file name is valid.

Parameters

string $fileName

File Name

Returns

boolean

isValidSeedFileName()

isValidSeedFileName(string  $fileName) : boolean

Check if a seed file name is valid.

Parameters

string $fileName

File Name

Returns

boolean