PHP Class Doctrine\DBAL\Migrations\Version

Since: 2.0
Author: Jonathan H. Wage ([email protected])
Show file Open project: doctrine/migrations Class Usage Examples

Public Methods

Method Description
__construct ( Configuration $configuration, $version, $class, Doctrine\DBAL\Migrations\Provider\SchemaDiffProviderInterface $schemaProvider = null )
__toString ( )
addSql ( array | string $sql, array $params = [], array $types = [] ) Add some SQL queries to this versions migration
execute ( string $direction, boolean $dryRun = false, boolean $timeAllQueries = false ) : array Execute this migration version up or down and and return the SQL.
getConfiguration ( ) : Configuration Returns the Migrations Configuration object instance
getExecutionState ( )
getMigration ( ) : Doctrine\DBAL\Migrations\AbstractMigration
getTime ( ) : integer Returns the time this migration version took to execute
getVersion ( ) : string Returns the string version in the format YYYYMMDDHHMMSS
isMigrated ( ) : boolean Check if this version has been migrated or not.
markMigrated ( )
markNotMigrated ( )
writeSqlFile ( string $path, string $direction = self::DIRECTION_UP ) : boolean Write a migration SQL file to the given path

Private Methods

Method Description
addQueryParams ( mixed[] $params, string[] $types )
executeRegisteredSql ( $dryRun = false, $timeAllQueries = false )
formatParamsForOutput ( array $params, array $types ) : string | null Formats a set of sql parameters for output with dry run.
markVersion ( $direction )
outputQueryTime ( $queryStart, $timeAllQueries = false )
outputSqlQuery ( integer $idx, string $query ) : void Outputs a SQL query via the OutputWriter.

Method Details

__construct() public method

public __construct ( Configuration $configuration, $version, $class, Doctrine\DBAL\Migrations\Provider\SchemaDiffProviderInterface $schemaProvider = null )
$configuration Doctrine\DBAL\Migrations\Configuration\Configuration
$schemaProvider Doctrine\DBAL\Migrations\Provider\SchemaDiffProviderInterface

__toString() public method

public __toString ( )

addSql() public method

Add some SQL queries to this versions migration
public addSql ( array | string $sql, array $params = [], array $types = [] )
$sql array | string
$params array
$types array

execute() public method

We are only allowing the addSql call and the schema modification to take effect in the up and down call. This is necessary to ensure that the migration is revertable. The schema is passed to the pre and post method only to be able to test the presence of some table, And the connection that can get used trough it allow for the test of the presence of records.
public execute ( string $direction, boolean $dryRun = false, boolean $timeAllQueries = false ) : array
$direction string The direction to execute the migration.
$dryRun boolean Whether to not actually execute the migration SQL and just do a dry run.
$timeAllQueries boolean Measuring or not the execution time of each SQL query.
return array $sql

getConfiguration() public method

Returns the Migrations Configuration object instance
public getConfiguration ( ) : Configuration
return Doctrine\DBAL\Migrations\Configuration\Configuration $configuration

getExecutionState() public method

public getExecutionState ( )

getMigration() public method

public getMigration ( ) : Doctrine\DBAL\Migrations\AbstractMigration
return Doctrine\DBAL\Migrations\AbstractMigration

getTime() public method

Returns the time this migration version took to execute
public getTime ( ) : integer
return integer $time The time this migration version took to execute

getVersion() public method

Returns the string version in the format YYYYMMDDHHMMSS
public getVersion ( ) : string
return string $version

isMigrated() public method

Check if this version has been migrated or not.
public isMigrated ( ) : boolean
return boolean

markMigrated() public method

public markMigrated ( )

markNotMigrated() public method

public markNotMigrated ( )

writeSqlFile() public method

Write a migration SQL file to the given path
public writeSqlFile ( string $path, string $direction = self::DIRECTION_UP ) : boolean
$path string The path to write the migration SQL file.
$direction string The direction to execute.
return boolean $written