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
array $db_info Database information for this connection
Overrides
|
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
string $from The version to start the upgrade from
- $to
string $to The version to upgrade to, null to upgrade to latest version
- $callback
callable $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
string $a A semantic version number
- $b
string $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
- $v
string $v The version to parse
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
string $from The version to start the upgrade from
- $to
string $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
string $obj The full path to the SQL file to execute
- $callback
callable $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
string $file The full path to the SQL file to execute
- $callback
callable $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
|
Methods inherited from Model
affectedRows()
,
begin()
,
commit()
,
getConnection()
,
lastInsertId()
,
makeDSN()
,
prepare()
,
query()
,
rollBack()
,
setAttribute()
,
setFetchMode()
Magic methods summary