PHP 클래스 MigrationShell

상속: extends AppShell
파일 보기 프로젝트 열기: cakedc/migrations

공개 프로퍼티들

프로퍼티 타입 설명
$Version MigrationVersion MigrationVersion instance
$connection null | string Connection used for the migration_schema table of the migration versions
$migrationConnection null | string This can be used to override the connection of migration file
$path string Current path to load and save migrations
$skip array Skip a version or it can skip many version using comma as separate.
$type string Type of migration, can be 'app' or a plugin name

보호된 프로퍼티들

프로퍼티 타입 설명
$_messages array Messages used to display action being performed

공개 메소드들

메소드 설명
afterMigration ( &$Migration, string $direction ) : void Callback used to create a new line after the migration
beforeAction ( &$Migration, string $type, array $data ) : void Callback used to display actions being performed
beforeMigration ( &$Migration, string $direction ) : void Callback used to display what migration is being runned
generate ( ) : void Generate a new migration file
getOptionParser ( ) : string Get the option parser.
main ( ) : void Override main
run ( ) : void Run the migrations
startup ( ) : void Override startup
status ( ) : void Displays a status of all plugin and app migrations

보호된 메소드들

메소드 설명
_connectionNamesEnum ( ) : array Get a list of connection names.
_execute ( array $options, boolean $once ) : boolean Execute migration
_fieldNamesArray ( array $fields ) : array Return list of field names from array of field/index definitions
_finalizeGeneratedMigration ( &$migration, &$migrationName, &$fromSchema ) : void Finalizes the generated migration - offers to preview it, prompts for a name, writes the file, and updates db version if needed.
_findSchemaFile ( Folder $folder, string $schemaFiles, string $name ) : mixed Finds schema file
_fromComparison ( array $migration, array $comparison, array $oldTables, array $currentTables ) : array Generate a migration string using comparison
_generateDump ( &$migration ) : void Generate a dump of the current database.
_generateFromCliArgs ( &$migration, &$migrationName, &$comparison ) : void Generate a migration from arguments passed in at the command line
_generateFromComparison ( &$migration, &$oldSchema, &$comparison ) : void Generate a migration by comparing schema.php with the database.
_generateFromInverseComparison ( &$migration, &$oldSchema, &$comparison ) : void Generate a migration by comparing the database with schema.php.
_generateMigration ( string $name, string $class, array $migration ) : string Generate a migration
_generateTemplate ( string $template, array $vars ) : string Include and generate a template string based on a template file
_getFieldType ( string $field, string $type, array $validTypes ) : string Return valid field type based on name of field
_getPath ( string $type = null ) : string Return the path used
_getSchema ( string $type = null ) : mixed Load and construct the schema class if exists
_getSchemaClassName ( string $name = null, boolean $suffix = true ) : string Gets the schema class name
_migrationChanges ( array $migration ) : boolean _migrationsChanges method
_outputLog ( array $log ) : void Output the SQL log in dry mode
_overwriteSchema ( ) : void Overwrite the schema.php file
_parseCommandLineFields ( string $name ) : array Parse fields from the command line for use with generating new migration files
_parseSingleCommandLineField ( &$fields, &$indexes, string $field, array $validTypes ) : void Parse a single argument from the command line into the fields array
_promptForMigrationName ( ) : string Prompt the user for a name for their new migration.
_promptVersionOptions ( array $mapping, string $latestVersion ) : array Output prompt with different migration versions to choose from
_readSchema ( ) : array Reads the schema data
_showInfo ( array $mapping, string $type = null ) : void Shows a list of available migrations
_singleStepOptions ( array $mapping, string $latestVersion, array $default = [] ) : array Single step options for up/down migrations
_startMigrationConnection ( ) : string Set a migration connection
_updateSchema ( ) : void Update the schema, making a call to schema shell
_values ( array $values ) : string Format a array/string into a one-line syntax
_writeMigration ( string $name, integer $version, array $migration ) : boolean Write a migration with given name

메소드 상세

_connectionNamesEnum() 보호된 메소드

Get a list of connection names.
protected _connectionNamesEnum ( ) : array
리턴 array The list of connection names

_execute() 보호된 메소드

Execute migration
protected _execute ( array $options, boolean $once ) : boolean
$options array Options for migration
$once boolean True to only run once, false to retry
리턴 boolean True if success

_fieldNamesArray() 보호된 메소드

Return list of field names from array of field/index definitions
protected _fieldNamesArray ( array $fields ) : array
$fields array Field/index definitions
리턴 array List of field names

_finalizeGeneratedMigration() 보호된 메소드

Finalizes the generated migration - offers to preview it, prompts for a name, writes the file, and updates db version if needed.
protected _finalizeGeneratedMigration ( &$migration, &$migrationName, &$fromSchema ) : void
리턴 void

_findSchemaFile() 보호된 메소드

Finds schema file
protected _findSchemaFile ( Folder $folder, string $schemaFiles, string $name ) : mixed
$folder Folder Folder object with schema folder path.
$schemaFiles string Schema files inside schema folder.
$name string Schema-class name.
리턴 mixed null in case of no file found, schema file.

_fromComparison() 보호된 메소드

Generate a migration string using comparison
protected _fromComparison ( array $migration, array $comparison, array $oldTables, array $currentTables ) : array
$migration array Migration instructions array
$comparison array Result from CakeSchema::compare()
$oldTables array List of tables on schema.php file
$currentTables array List of current tables on database
리턴 array

_generateDump() 보호된 메소드

Generate a dump of the current database.
protected _generateDump ( &$migration ) : void
리턴 void (The variables passed by reference are changed; nothing is returned)

_generateFromCliArgs() 보호된 메소드

Generate a migration from arguments passed in at the command line
protected _generateFromCliArgs ( &$migration, &$migrationName, &$comparison ) : void
리턴 void (The variables passed by reference are changed; nothing is returned)

_generateFromComparison() 보호된 메소드

Generate a migration by comparing schema.php with the database.
protected _generateFromComparison ( &$migration, &$oldSchema, &$comparison ) : void
리턴 void (The variables passed by reference are changed; nothing is returned)

_generateFromInverseComparison() 보호된 메소드

Generate a migration by comparing the database with schema.php.
protected _generateFromInverseComparison ( &$migration, &$oldSchema, &$comparison ) : void
리턴 void (The variables passed by reference are changed; nothing is returned)

_generateMigration() 보호된 메소드

Generate a migration
protected _generateMigration ( string $name, string $class, array $migration ) : string
$name string Name of migration
$class string Class name of migration
$migration array Migration instructions array
리턴 string

_generateTemplate() 보호된 메소드

Include and generate a template string based on a template file
protected _generateTemplate ( string $template, array $vars ) : string
$template string Template file name
$vars array List of variables to be used on tempalte
리턴 string

_getFieldType() 보호된 메소드

Return valid field type based on name of field
protected _getFieldType ( string $field, string $type, array $validTypes ) : string
$field string Name of field
$type string Current type
$validTypes array List of valid types
리턴 string Recognized type (eg. integer vs bigint)

_getPath() 보호된 메소드

Return the path used
protected _getPath ( string $type = null ) : string
$type string Can be 'app' or a plugin name
리턴 string Path used

_getSchema() 보호된 메소드

Load and construct the schema class if exists
protected _getSchema ( string $type = null ) : mixed
$type string Can be 'app' or a plugin name
리턴 mixed False in case of no file found, schema object

_getSchemaClassName() 보호된 메소드

Gets the schema class name
protected _getSchemaClassName ( string $name = null, boolean $suffix = true ) : string
$name string Can be 'app' or a plugin name
$suffix boolean Return the class name with or without the "Schema" suffix, default is true
리턴 string Returns the schema class name

_migrationChanges() 보호된 메소드

_migrationsChanges method
protected _migrationChanges ( array $migration ) : boolean
$migration array list of migrations
리턴 boolean

_outputLog() 보호된 메소드

Output the SQL log in dry mode
protected _outputLog ( array $log ) : void
$log array List of queries per migration
리턴 void

_overwriteSchema() 보호된 메소드

Overwrite the schema.php file
protected _overwriteSchema ( ) : void
리턴 void

_parseCommandLineFields() 보호된 메소드

Parse fields from the command line for use with generating new migration files
protected _parseCommandLineFields ( string $name ) : array
$name string Name of migration
리턴 array

_parseSingleCommandLineField() 보호된 메소드

Parse a single argument from the command line into the fields array
protected _parseSingleCommandLineField ( &$fields, &$indexes, string $field, array $validTypes ) : void
$field string A single command line argument - eg. 'id:primary_key' or 'name:string'
$validTypes array Valid data types for the relevant database - eg. string, integer, biginteger, etc.
리턴 void

_promptForMigrationName() 보호된 메소드

Prompt the user for a name for their new migration.
protected _promptForMigrationName ( ) : string
리턴 string

_promptVersionOptions() 보호된 메소드

Output prompt with different migration versions to choose from
protected _promptVersionOptions ( array $mapping, string $latestVersion ) : array
$mapping array Migration version mappings
$latestVersion string Latest migration version
리턴 array User-chosen options for migration

_readSchema() 보호된 메소드

Reads the schema data
protected _readSchema ( ) : array
리턴 array

_showInfo() 보호된 메소드

Shows a list of available migrations
protected _showInfo ( array $mapping, string $type = null ) : void
$mapping array Migration mapping
$type string Can be 'app' or a plugin name
리턴 void

_singleStepOptions() 보호된 메소드

Single step options for up/down migrations
protected _singleStepOptions ( array $mapping, string $latestVersion, array $default = [] ) : array
$mapping array Migration version mappings
$latestVersion string Latest migration version
$default array Default options for migration
리턴 array Modified options for migration

_startMigrationConnection() 보호된 메소드

Set a migration connection
protected _startMigrationConnection ( ) : string
리턴 string The name of the migration connection.

_updateSchema() 보호된 메소드

Update the schema, making a call to schema shell
protected _updateSchema ( ) : void
리턴 void

_values() 보호된 메소드

Format a array/string into a one-line syntax
protected _values ( array $values ) : string
$values array Array to be converted
리턴 string

_writeMigration() 보호된 메소드

Write a migration with given name
protected _writeMigration ( string $name, integer $version, array $migration ) : boolean
$name string Name of migration
$version integer The version number (timestamp)
$migration array Migration instructions array
리턴 boolean

afterMigration() 공개 메소드

Callback used to create a new line after the migration
public afterMigration ( &$Migration, string $direction ) : void
$direction string Direction being runned
리턴 void

beforeAction() 공개 메소드

Callback used to display actions being performed
public beforeAction ( &$Migration, string $type, array $data ) : void
$type string Type of action. i.e: create_table, drop_table, etc.
$data array Data to send to the callback
리턴 void

beforeMigration() 공개 메소드

Additionally, shows the generation date of the migration, if the version is greater than '2000-01-01'.
public beforeMigration ( &$Migration, string $direction ) : void
$direction string Direction being runned
리턴 void

generate() 공개 메소드

Generate a new migration file
public generate ( ) : void
리턴 void

getOptionParser() 공개 메소드

Get the option parser.
public getOptionParser ( ) : string
리턴 string

main() 공개 메소드

Override main
public main ( ) : void
리턴 void

run() 공개 메소드

Run the migrations
public run ( ) : void
리턴 void

startup() 공개 메소드

Override startup
public startup ( ) : void
리턴 void

status() 공개 메소드

Displays a status of all plugin and app migrations
public status ( ) : void
리턴 void

프로퍼티 상세

$Version 공개적으로 프로퍼티

MigrationVersion instance
public MigrationVersion $Version
리턴 MigrationVersion

$_messages 보호되어 있는 프로퍼티

Messages used to display action being performed
protected array $_messages
리턴 array

$connection 공개적으로 프로퍼티

Connection used for the migration_schema table of the migration versions
public null|string $connection
리턴 null | string

$migrationConnection 공개적으로 프로퍼티

This can be used to override the connection of migration file
public null|string $migrationConnection
리턴 null | string

$path 공개적으로 프로퍼티

Current path to load and save migrations
public string $path
리턴 string

$skip 공개적으로 프로퍼티

Skip a version or it can skip many version using comma as separate.
public array $skip
리턴 array

$type 공개적으로 프로퍼티

Type of migration, can be 'app' or a plugin name
public string $type
리턴 string