Stud.IP  5.4
Migrator Class Reference

Public Member Functions

 __construct ($migrations_path, SchemaVersion $version, $verbose=false)
 
 migrateTo ($target_version)
 
 targetVersions ($target_version)
 
 relevantMigrations ($target_version)
 
 migrationClasses ()
 
 migrationBranchAndVersion ($version)
 
 topVersion ($all_branches=false)
 
 pendingMigrations ()
 

Protected Member Functions

 migrationClass ($migration)
 
 migrationFiles ()
 
 migrationVersionAndName ($migration_file)
 
 log ($format)
 

Constructor & Destructor Documentation

◆ __construct()

__construct (   $migrations_path,
SchemaVersion  $version,
  $verbose = false 
)

Constructor.

Parameters
stringa file path to the directory containing the migration files
SchemaVersionthe current schema version persistor
booleanverbose or not
Returns
void

Member Function Documentation

◆ log()

log (   $format)
protected

Overridable method used to return a textual representation of what's going on in me. You can use me as you would use printf.

Parameters
string$formatjust a dummy value, instead use this method as you would use printf & co.

◆ migrateTo()

migrateTo (   $target_version)

Invoking this method will perform the migrations with an index between the current schema version (provided by the SchemaVersion object) and a target version calling the methods #up and #down in sequence.

Parameters
mixedthe target version as an integer, array or NULL thus migrating to the top migrations

◆ migrationBranchAndVersion()

migrationBranchAndVersion (   $version)

Split a migration version into its branch and version parts.

Parameters
stringa migration version
Returns
array an array of two elements containing the migration's branch and version on this branch.

◆ migrationClass()

migrationClass (   $migration)
protected

Maps a file name to a class name.

Parameters
stringpart of the file name
Returns
string the derived class name

◆ migrationClasses()

migrationClasses ( )

Returns the collection (an array) of all migrations in this migrator's path.

Returns
array an associative array, whose keys are the migration's version and whose values are arrays containing the migration's file and class name.

◆ migrationFiles()

migrationFiles ( )
protected

Return all migration file names from my migrations_path.

Returns
array a collection of file names

◆ migrationVersionAndName()

migrationVersionAndName (   $migration_file)
protected

Split a migration file name into that migration's version and name.

Parameters
stringa file name
Returns
array an array of two elements containing the migration's version and name.

◆ pendingMigrations()

pendingMigrations ( )

Returns the number of available, but not yet applied migrations.

Returns
int migration count

◆ relevantMigrations()

relevantMigrations (   $target_version)

Invoking this method will return a list of migrations with an index between the current schema version (provided by the SchemaVersion object) and a target version calling the methods #up and #down in sequence.

Parameters
mixedthe target version as an integer, array or NULL thus migrating to the top migrations
Returns
array an associative array, whose keys are the migration's version and whose values are the migration objects

◆ targetVersions()

targetVersions (   $target_version)

Calculate the selected target versions for all relevant branches. If a single branch is selected for migration, only that branch and all its children are considered relevant.

Parameters
mixedthe target version as an integer, array or NULL thus migrating to the top migrations
Returns
array an associative array, whose keys are the branch names and whose values are the target versions

◆ topVersion()

topVersion (   $all_branches = false)

Returns the top migration's version.

Parameters
boolreturn top version for all branches, not just default one
Returns
int the top migration's version.

The documentation for this class was generated from the following file: