class Doctrine_Migration (View source)

Doctrine_Migration

this class represents a database view

Properties

protected $_migrationTableName
protected $_migrationTableCreated
protected $_connection
protected $_migrationClassesDirectory
protected $_migrationClasses
protected $_reflectionClass
protected $_errors
protected $_process
static protected $_migrationClassesForDirectories

Methods

void
__construct(string $directory = null, mixed $connection = null)

Specify the path to the directory with the migration classes.

getConnection()

No description

setConnection(Doctrine_Connection $conn)

No description

string
getMigrationClassesDirectory()

Get the migration classes directory

string
getTableName()

Get the table name for storing the version number for this migration instance

void
setTableName(string $tableName)

Set the table name for storing the version number for this migration instance

void
loadMigrationClassesFromDirectory(string $directory = null)

Load migration classes from the passed directory. Any file found with a .php extension will be passed to the loadMigrationClass()

void
loadMigrationClass($name, $path = null)

Load the specified migration class name in to this migration instances queue of migration classes to execute. It must be a child of Doctrine_Migration in order to be loaded.

array
getMigrationClasses()

Get all the loaded migration classes. Array where key is the number/version and the value is the class name.

void
setCurrentVersion(integer $number)

Set the current version of the database

integer
getCurrentVersion()

Get the current version of the database

boolean
hasMigrated()

hReturns true/false for whether or not this database has been migrated in the past

integer
getLatestVersion()

Gets the latest possible version from the loaded migration classes

integer
getNextVersion()

Get the next incremented version number based on the latest version number using getLatestVersion()

integer
getNextMigrationClassVersion()

Get the next incremented class version based on the loaded migration classes

integer
migrate(integer $to = null, boolean $dryRun = false)

Perform a migration process by specifying the migration number/version to migrate to. It will automatically know whether you are migrating up or down based on the current version of the database.

boolean
migrateDryRun(string $to = null)

Run the migration process but rollback at the very end. Returns true or false for whether or not the migration can be ran

integer
getNumErrors()

Get the number of errors

array
getErrors()

Get all the error exceptions

void
clearErrors()

Clears the error exceptions

void
addError(Exception $e)

Add an error to the stack. Excepts some type of Exception

boolean
hasErrors()

Whether or not the migration instance has errors

getMigrationClass(integer $num)

Get instance of migration class for number/version specified

void
_throwErrorsException()

Throw an exception with all the errors trigged during the migration

integer
_doMigrate(integer $to)

Do the actual migration process

void
_doMigrateStep(string $direction, integer $num)

Perform a single migration step. Executes a single migration class and processes the changes

boolean
_createMigrationTable()

Create the migration table and return true. If it already exists it will silence the exception and return false

Details

void __construct(string $directory = null, mixed $connection = null)

Specify the path to the directory with the migration classes.

The classes will be loaded and the migration table will be created if it does not already exist

Parameters

string $directory The path to your migrations directory
mixed $connection The connection name or instance to use for this migration

Return Value

void

getConnection()

setConnection(Doctrine_Connection $conn)

Parameters

Doctrine_Connection $conn

string getMigrationClassesDirectory()

Get the migration classes directory

Return Value

string $migrationClassesDirectory

string getTableName()

Get the table name for storing the version number for this migration instance

Return Value

string $migrationTableName

void setTableName(string $tableName)

Set the table name for storing the version number for this migration instance

Parameters

string $tableName

Return Value

void

void loadMigrationClassesFromDirectory(string $directory = null)

Load migration classes from the passed directory. Any file found with a .php extension will be passed to the loadMigrationClass()

Parameters

string $directory Directory to load migration classes from

Return Value

void

void loadMigrationClass($name, $path = null)

Load the specified migration class name in to this migration instances queue of migration classes to execute. It must be a child of Doctrine_Migration in order to be loaded.

Parameters

$name
$path

Return Value

void

array getMigrationClasses()

Get all the loaded migration classes. Array where key is the number/version and the value is the class name.

Return Value

array $migrationClasses

void setCurrentVersion(integer $number)

Set the current version of the database

Parameters

integer $number

Return Value

void

integer getCurrentVersion()

Get the current version of the database

Return Value

integer $version

boolean hasMigrated()

hReturns true/false for whether or not this database has been migrated in the past

Return Value

boolean $migrated

integer getLatestVersion()

Gets the latest possible version from the loaded migration classes

Return Value

integer $latestVersion

integer getNextVersion()

Get the next incremented version number based on the latest version number using getLatestVersion()

Return Value

integer $nextVersion

integer getNextMigrationClassVersion()

Get the next incremented class version based on the loaded migration classes

Return Value

integer $nextMigrationClassVersion

integer migrate(integer $to = null, boolean $dryRun = false)

Perform a migration process by specifying the migration number/version to migrate to. It will automatically know whether you are migrating up or down based on the current version of the database.

Parameters

integer $to Version to migrate to
boolean $dryRun Whether or not to run the migrate process as a dry run

Return Value

integer $to Version number migrated to

Exceptions

Doctrine_Exception

boolean migrateDryRun(string $to = null)

Run the migration process but rollback at the very end. Returns true or false for whether or not the migration can be ran

Parameters

string $to

Return Value

boolean $success

integer getNumErrors()

Get the number of errors

Return Value

integer $numErrors

array getErrors()

Get all the error exceptions

Return Value

array $errors

void clearErrors()

Clears the error exceptions

Return Value

void

void addError(Exception $e)

Add an error to the stack. Excepts some type of Exception

Parameters

Exception $e

Return Value

void

boolean hasErrors()

Whether or not the migration instance has errors

Return Value

boolean

getMigrationClass(integer $num)

Get instance of migration class for number/version specified

Parameters

integer $num

Exceptions

Doctrine_Migration_Exception $e

protected void _throwErrorsException()

Throw an exception with all the errors trigged during the migration

Return Value

void

Exceptions

Doctrine_Migration_Exception $e

protected integer _doMigrate(integer $to)

Do the actual migration process

Parameters

integer $to

Return Value

integer $to

Exceptions

Doctrine_Exception

protected void _doMigrateStep(string $direction, integer $num)

Perform a single migration step. Executes a single migration class and processes the changes

Parameters

string $direction Direction to go, 'up' or 'down'
integer $num

Return Value

void

protected boolean _createMigrationTable()

Create the migration table and return true. If it already exists it will silence the exception and return false

Return Value

boolean $created Whether or not the table was created. Exceptions are silenced when table already exists