PHP 클래스 yii\console\controllers\MigrateController

A migration means a set of persistent changes to the application environment that is shared among different developers. For example, in an application backed by a database, a migration may refer to a set of changes to the database, such as creating a new table, adding a new table column. This command provides support for tracking the migration history, upgrading or downloading with migrations, and creating new migration skeletons. The migration history is stored in a database table named as [[migrationTable]]. The table will be automatically created the first time this command is executed, if it does not exist. You may also manually create it as follows: ~~~ CREATE TABLE migration ( version varchar(180) PRIMARY KEY, apply_time integer ) ~~~ Below are some common usages of this command: ~~~ # creates a new migration named 'create_user_table' yii migrate/create create_user_table # applies ALL new migrations yii migrate # reverts the last applied migration yii migrate/down ~~~
부터: 2.0
저자: Qiang Xue ([email protected])
상속: extends BaseMigrateController
파일 보기 프로젝트 열기: yiisoft/yii2 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$db the DB connection object or the application component ID of the DB connection to use when applying migrations. Starting from version 2.0.3, this can also be a configuration array for creating the object.
$fields column definition strings used for creating migration code. The format of each definition is COLUMN_NAME:COLUMN_TYPE:COLUMN_DECORATOR. Delimiter is ,. For example, --fields="name:string(12):notNull:unique" produces a string column of size 12 which is not null and unique values. Note: primary key is added automatically and is named id by default. If you want to use another name you may specify it explicitly like --fields="id_key:primaryKey,name:string(12):notNull:unique"
$generatorTemplateFiles a set of template paths for generating migration code automatically. The key is the template type, the value is a path or the alias. Supported types are: - create_table: table creating template - drop_table: table dropping template - add_column: adding new column template - drop_column: dropping column template - create_junction: create junction template
$migrationTable the name of the table for keeping applied migration information.
$templateFile
$useTablePrefix indicates whether the table names generated should consider the tablePrefix setting of the DB connection. For example, if the table name is post the generator wil return {{%post}}.

공개 메소드들

메소드 설명
beforeAction ( Action $action ) : boolean This method is invoked right before an action is to be executed (after all possible filters.) It checks the existence of the [[migrationPath]].
optionAliases ( )
options ( $actionID )

보호된 메소드들

메소드 설명
addDefaultPrimaryKey ( array &$fields ) Adds default primary key to fields list if there's no primary key specified
addMigrationHistory ( $version )
createMigration ( string $class ) : Migration Creates a new migration instance.
createMigrationHistoryTable ( ) Creates the migration history table.
generateMigrationSourceCode ( $params )
generateTableName ( string $tableName ) : string If useTablePrefix equals true, then the table name will contain the prefix format.
getMigrationHistory ( $limit )
parseFields ( ) : array Parse the command line migration fields
removeMigrationHistory ( $version )

메소드 상세

addDefaultPrimaryKey() 보호된 메소드

Adds default primary key to fields list if there's no primary key specified
부터: 2.0.7
protected addDefaultPrimaryKey ( array &$fields )
$fields array parsed fields

addMigrationHistory() 보호된 메소드

protected addMigrationHistory ( $version )

beforeAction() 공개 메소드

This method is invoked right before an action is to be executed (after all possible filters.) It checks the existence of the [[migrationPath]].
public beforeAction ( Action $action ) : boolean
$action yii\base\Action the action to be executed.
리턴 boolean whether the action should continue to be executed.

createMigration() 보호된 메소드

Creates a new migration instance.
protected createMigration ( string $class ) : Migration
$class string the migration class name
리턴 yii\db\Migration the migration instance

createMigrationHistoryTable() 보호된 메소드

Creates the migration history table.

generateMigrationSourceCode() 보호된 메소드

부터: 2.0.8
protected generateMigrationSourceCode ( $params )

generateTableName() 보호된 메소드

If useTablePrefix equals true, then the table name will contain the prefix format.
부터: 2.0.8
protected generateTableName ( string $tableName ) : string
$tableName string the table name to generate.
리턴 string

getMigrationHistory() 보호된 메소드

protected getMigrationHistory ( $limit )

optionAliases() 공개 메소드

부터: 2.0.8
public optionAliases ( )

options() 공개 메소드

public options ( $actionID )

parseFields() 보호된 메소드

Parse the command line migration fields
부터: 2.0.7
protected parseFields ( ) : array
리턴 array parse result with following fields: - fields: array, parsed fields - foreignKeys: array, detected foreign keys

removeMigrationHistory() 보호된 메소드

protected removeMigrationHistory ( $version )

프로퍼티 상세

$db 공개적으로 프로퍼티

the DB connection object or the application component ID of the DB connection to use when applying migrations. Starting from version 2.0.3, this can also be a configuration array for creating the object.
public $db

$fields 공개적으로 프로퍼티

column definition strings used for creating migration code. The format of each definition is COLUMN_NAME:COLUMN_TYPE:COLUMN_DECORATOR. Delimiter is ,. For example, --fields="name:string(12):notNull:unique" produces a string column of size 12 which is not null and unique values. Note: primary key is added automatically and is named id by default. If you want to use another name you may specify it explicitly like --fields="id_key:primaryKey,name:string(12):notNull:unique"
부터: 2.0.7
public $fields

$generatorTemplateFiles 공개적으로 프로퍼티

a set of template paths for generating migration code automatically. The key is the template type, the value is a path or the alias. Supported types are: - create_table: table creating template - drop_table: table dropping template - add_column: adding new column template - drop_column: dropping column template - create_junction: create junction template
부터: 2.0.7
public $generatorTemplateFiles

$migrationTable 공개적으로 프로퍼티

the name of the table for keeping applied migration information.
public $migrationTable

$templateFile 공개적으로 프로퍼티

public $templateFile

$useTablePrefix 공개적으로 프로퍼티

indicates whether the table names generated should consider the tablePrefix setting of the DB connection. For example, if the table name is post the generator wil return {{%post}}.
부터: 2.0.8
public $useTablePrefix