PHP 클래스 MigrationVersion

파일 보기 프로젝트 열기: cakedc/migrations 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$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.

보호된 프로퍼티들

프로퍼티 타입 설명
$_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