Class Upgrades
Handles the upgrade process to bring the current database up to the
requirements of the installed files.
-
Model
-
Upgrades
Methods summary
public
|
#
__construct( array $db_info = null )
Setup
Parameters
- $db_info
- The database connection information (optional)
|
public
array
|
#
getMappings( )
Returns all upgrade mappings
Returns all upgrade mappings
Returns
array An array in key/value pairs where each key is the version from and each value is the version to
|
public
|
#
start( string $from, string $to, callable $callback = null )
Starts the upgrade process
Starts the upgrade process
Parameters
- $from
- The version to start the upgrade from
- $to
- The version to upgrade to, null to upgrade to latest version
- $callback
- The callback to execute after each task in the upgrade process (for each version)
|
public
array
|
#
compareVersions( string $a, string $b )
Compares to semantic version numbers and returns the result
Compares to semantic version numbers and returns the result
Parameters
- $a
- A semantic version number
- $b
- A semantic version number
Returns
array An array containing the comparison of the two versions, including:
- major How major $a compares to $b (>, <, =)
- minor How minor $a compares to $b (>, <, =)
- patch How patch $a compares to $b (>, <, =)
- pre How pre release $a compares to $b (>, <, =)
- build How build meta data $a compare to $b (>, <, =)
- diff How $a and $b differ (major, minor, patch, pre, build, null if versions are identical)
- latest Either $a or $b, whichever is newer
|
public
array
|
#
parseVersion( string $v )
Parse the given semantic version number
Parse the given semantic version number
Parameters
Returns
array An array containing version info:
- major
- minor
- patch
- pre
- build
|
public
|
#
getUpgrades( string $from, string $to )
Generates a mapping of all files
Generates a mapping of all files
Parameters
- $from
- The version to start the upgrade from
- $to
- The version to upgrade to, null to upgrade to latest version
Throws
Exception Thrown if the required upgrade files are not present
|
public
|
#
processObject( string $obj, callable $callback = null )
Processes the given object, passes the callback to the object
by passing the current task count being executed and the total number
of tasks to be executed for that object.
Processes the given object, passes the callback to the object
by passing the current task count being executed and the total number
of tasks to be executed for that object.
Parameters
- $obj
- The full path to the SQL file to execute
- $callback
- The callback to execute after each task in the upgrade process
|
public
|
#
processSql( string $file, callable $callback = null )
Processes the given SQL file, executes the given callback after each query
by passing the current query number being executed and the total number
of queries to be executed for that file.
Processes the given SQL file, executes the given callback after each query
by passing the current query number being executed and the total number
of queries to be executed for that file.
Parameters
- $file
- The full path to the SQL file to execute
- $callback
- The callback to execute after each query
Throws
PDOExcetion if any query fails
|
public
array
|
#
errors( )
Return all errors
Returns
array An array of errors
|