PHP Класс MigrationVersion

Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$Version Model Instance of SchemaMigrations model
$connection string Connection used for the migration_schema table of the migration versions
$dry boolean If try, the SQL will be outputted to screen rather than applied to the database
$jumpTo null | string Jump to a certain migration.
$log array This is used for dry run
$migrationConnection null | string This can be used to override the connection of migration file
$precheck string Precheck mode
$skip array Skip a version or it can skip many version using comma as separate.

Защищенные свойства (Protected)

Свойство Тип Описание
$_mapping array Mapping cache

Открытые методы

Метод Описание
__construct ( array $options = [] ) Constructor
getMapping ( string $type, boolean $cache = true ) : mixed Get mapping for the given type
getMigration ( string $name, string $class, string $type, array $options = [] ) : boolean | CakeMigration Load and make a instance of the migration
getVersion ( string $type ) : integer Get last version for given type
getVersionByName ( array $mapping ) : boolean | string Will return a version based in the migration name
initVersion ( ) : void Get a new SchemaMigration instance
jump ( array $version, array $type ) : void Jump to a certain migration and mark the preceding migrations as executed.
run ( array $options ) : boolean Run the migrations
setVersion ( integer $version, string $type, boolean $migrated = true ) : boolean Set current version for given type

Защищенные методы

Метод Описание
_enumerateMigrations ( string $type ) : array Returns a map of all available migrations for a type (app or plugin)
_enumerateNewMigrations ( string $type ) : array Returns a map of all available migrations for a type (app or plugin) using inflection
_enumerateOldMigrations ( string $type ) : array Returns a map of all available migrations for a type (app or plugin) using regular expressions
_initMigrations ( ) : void Initialize the migrations schema and keep it up-to-date
_loadFile ( string $name, string $type ) : mixed Load a file based on name and type

Описание методов

__construct() публичный Метод

Constructor
public __construct ( array $options = [] )
$options array optional load object properties

_enumerateMigrations() защищенный Метод

Returns a map of all available migrations for a type (app or plugin)
protected _enumerateMigrations ( string $type ) : array
$type string Can be 'app' or a plugin name
Результат array containing a list of migration versions ordered by filename

_enumerateNewMigrations() защищенный Метод

Returns a map of all available migrations for a type (app or plugin) using inflection
protected _enumerateNewMigrations ( string $type ) : array
$type string Can be 'app' or a plugin name
Результат array containing a list of migration versions ordered by filename

_enumerateOldMigrations() защищенный Метод

Returns a map of all available migrations for a type (app or plugin) using regular expressions
protected _enumerateOldMigrations ( string $type ) : array
$type string Can be 'app' or a plugin name
Результат array containing a list of migration versions ordered by filename

_initMigrations() защищенный Метод

Initialize the migrations schema and keep it up-to-date
protected _initMigrations ( ) : void
Результат void

_loadFile() защищенный Метод

Load a file based on name and type
protected _loadFile ( string $name, string $type ) : mixed
$name string File name to be loaded
$type string Can be 'app' or a plugin name
Результат mixed Throw an exception in case of no file found, array with mapping

getMapping() публичный Метод

Get mapping for the given type
public getMapping ( string $type, boolean $cache = true ) : mixed
$type string Can be 'app' or a plugin name
$cache boolean Whether to return the cached value or not
Результат mixed False in case of no file found or empty mapping, array with mapping

getMigration() публичный Метод

Load and make a instance of the migration
public getMigration ( string $name, string $class, string $type, array $options = [] ) : boolean | CakeMigration
$name string File name where migration resides
$class string Migration class name
$type string Can be 'app' or a plugin name
$options array Extra options to send to CakeMigration class
Результат boolean | CakeMigration False in case of no file found, instance of the migration

getVersion() публичный Метод

Get last version for given type
public getVersion ( string $type ) : integer
$type string Can be 'app' or a plugin name
Результат integer Last version migrated

getVersionByName() публичный Метод

Will return a version based in the migration name
public getVersionByName ( array $mapping ) : boolean | string
$mapping array mapping of all migrations.
Результат boolean | string

initVersion() публичный Метод

Get a new SchemaMigration instance
public initVersion ( ) : void
Результат void

jump() публичный Метод

Jump to a certain migration and mark the preceding migrations as executed.
public jump ( array $version, array $type ) : void
$version array Version of a migration to jump to.
$type array migration type
Результат void

run() публичный Метод

Options: - direction - Direction to run - version - Until what version want migrate to
public run ( array $options ) : boolean
$options array An array with options.
Результат boolean

setVersion() публичный Метод

Set current version for given type
public setVersion ( integer $version, string $type, boolean $migrated = true ) : boolean
$version integer Current version
$type string Can be 'app' or a plugin name
$migrated boolean If true, will add the record to the database If false, will remove the record from the database
Результат boolean

Описание свойств

$Version публичное свойство

Instance of SchemaMigrations model
public Model $Version
Результат Model

$_mapping защищенное свойство

Mapping cache
protected array $_mapping
Результат array

$connection публичное свойство

Connection used for the migration_schema table of the migration versions
public string $connection
Результат string

$dry публичное свойство

If try, the SQL will be outputted to screen rather than applied to the database
public bool $dry
Результат boolean

$jumpTo публичное свойство

Jump to a certain migration.
public null|string $jumpTo
Результат null | string

$log публичное свойство

This is used for dry run
public array $log
Результат array

$migrationConnection публичное свойство

This can be used to override the connection of migration file
public null|string $migrationConnection
Результат null | string

$precheck публичное свойство

Precheck mode
public string $precheck
Результат string

$skip публичное свойство

Skip a version or it can skip many version using comma as separate.
public array $skip
Результат array