PHP Class Doctrine\DBAL\Migrations\Version

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

Méthodes publiques

Méthode 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

Méthode 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 méthode

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 méthode

public __toString ( )

addSql() public méthode

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 méthode

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.
Résultat array $sql

getConfiguration() public méthode

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

getExecutionState() public méthode

public getExecutionState ( )

getMigration() public méthode

public getMigration ( ) : Doctrine\DBAL\Migrations\AbstractMigration
Résultat Doctrine\DBAL\Migrations\AbstractMigration

getTime() public méthode

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

getVersion() public méthode

Returns the string version in the format YYYYMMDDHHMMSS
public getVersion ( ) : string
Résultat string $version

isMigrated() public méthode

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

markMigrated() public méthode

public markMigrated ( )

markNotMigrated() public méthode

public markNotMigrated ( )

writeSqlFile() public méthode

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.
Résultat boolean $written