PHP 클래스 console\controllers\MigrateController

Class MigrateController
상속: extends yii\console\controllers\MigrateController
파일 보기 프로젝트 열기: yeesoft/yii2-yee-cms

공개 프로퍼티들

프로퍼티 타입 설명
$db the DB connection object or the application component ID of the DB connection.
$defaultAction the default command action.
$disableLookup lookup all application migration paths
$interactive whether to execute the migration in an interactive mode.
$migrationLookup additional aliases of migration directories
$migrationPath the directory storing the migration classes. This can be either a path alias or a directory.
$migrationTable the name of the table for keeping applied migration information.
$templateFile the template file for generating new migrations. This can be either a path alias (e.g. "@app/migrations/template.php") or a file path.

공개 메소드들

메소드 설명
actionCreate ( string $name ) Creates a new migration.
actionDown ( integer $limit = 1 ) Downgrades the application by reverting old migrations.
actionHistory ( integer $limit = 10 ) Displays the migration history.
actionMark ( string $version ) Modifies the migration history to the specified version.
actionNew ( integer $limit = 10 ) Displays the un-applied new migrations.
actionRedo ( integer $limit = 1 ) Redoes the last few migrations.
actionTo ( string $version ) Upgrades or downgrades till the specified version.
actionUp ( integer $limit ) Upgrades the application by applying new migrations.
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]].
options ( $actionId )

보호된 메소드들

메소드 설명
createMigration ( string $class, $alias ) : Migration Creates a new migration instance.
createMigrationHistoryTable ( ) Creates the migration history table.
getMigrationHistory ( integer $limit ) : array Returns the migration history.
getNewMigrations ( ) : array Returns the migrations that are not applied.
migrateDown ( string $class, $alias ) : boolean Downgrades with the specified migration class.
migrateToTime ( integer $time ) Migrates to the specified apply time in the past.
migrateToVersion ( string $version ) Migrates to the certain version.
migrateUp ( string $class, $alias ) : boolean Upgrades with the specified migration class.

메소드 상세

actionCreate() 공개 메소드

This command creates a new migration using the available migration template. After using this command, developers should modify the created migration skeleton by filling up the actual migration logic. ~~~ yii migrate/create create_user_table ~~~
public actionCreate ( string $name )
$name string the name of the new migration. This should only contain letters, digits and/or underscores.

actionDown() 공개 메소드

For example, ~~~ yii migrate/down # revert the last migration yii migrate/down 3 # revert the last 3 migrations ~~~
public actionDown ( integer $limit = 1 )
$limit integer the number of migrations to be reverted. Defaults to 1, meaning the last applied migration will be reverted.

actionHistory() 공개 메소드

This command will show the list of migrations that have been applied so far. For example, ~~~ yii migrate/history # showing the last 10 migrations yii migrate/history 5 # showing the last 5 migrations yii migrate/history 0 # showing the whole history ~~~
public actionHistory ( integer $limit = 10 )
$limit integer the maximum number of migrations to be displayed. If it is 0, the whole migration history will be displayed.

actionMark() 공개 메소드

No actual migration will be performed. ~~~ yii migrate/mark 101129_185401 # using timestamp yii migrate/mark m101129_185401_create_user_table # using full name ~~~
public actionMark ( string $version )
$version string the version at which the migration history should be marked. This can be either the timestamp or the full name of the migration.

actionNew() 공개 메소드

This command will show the new migrations that have not been applied. For example, ~~~ yii migrate/new # showing the first 10 new migrations yii migrate/new 5 # showing the first 5 new migrations yii migrate/new 0 # showing all new migrations ~~~
public actionNew ( integer $limit = 10 )
$limit integer the maximum number of new migrations to be displayed. If it is 0, all available new migrations will be displayed.

actionRedo() 공개 메소드

This command will first revert the specified migrations, and then apply them again. For example, ~~~ yii migrate/redo # redo the last applied migration yii migrate/redo 3 # redo the last 3 applied migrations ~~~
public actionRedo ( integer $limit = 1 )
$limit integer the number of migrations to be redone. Defaults to 1, meaning the last applied migration will be redone.

actionTo() 공개 메소드

Can also downgrade versions to the certain apply time in the past by providing a UNIX timestamp or a string parseable by the strtotime() function. This means that all the versions applied after the specified certain time would be reverted. This command will first revert the specified migrations, and then apply them again. For example, ~~~ yii migrate/to 101129_185401 # using timestamp yii migrate/to m101129_185401_create_user_table # using full name yii migrate/to 1392853618 # using UNIX timestamp yii migrate/to "2014-02-15 13:00:50" # using strtotime() parseable string ~~~
public actionTo ( string $version )
$version string either the version name or the certain time value in the past that the application should be migrated to. This can be either the timestamp, the full name of the migration, the UNIX timestamp, or the parseable datetime string.

actionUp() 공개 메소드

For example, ~~~ yii migrate # apply all new migrations yii migrate 3 # apply the first 3 new migrations ~~~
public actionUp ( integer $limit )
$limit integer the number of new migrations to be applied. If 0, it means applying all available new migrations.

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, $alias ) : Migration
$class string the migration class name
리턴 yii\db\Migration the migration instance

createMigrationHistoryTable() 보호된 메소드

Creates the migration history table.

getMigrationHistory() 보호된 메소드

Returns the migration history.
protected getMigrationHistory ( integer $limit ) : array
$limit integer the maximum number of records in the history to be returned
리턴 array the migration history

getNewMigrations() 보호된 메소드

Returns the migrations that are not applied.
protected getNewMigrations ( ) : array
리턴 array list of new migrations, (key: migration version; value: alias)

migrateDown() 보호된 메소드

Downgrades with the specified migration class.
protected migrateDown ( string $class, $alias ) : boolean
$class string the migration class name
리턴 boolean whether the migration is successful

migrateToTime() 보호된 메소드

Migrates to the specified apply time in the past.
protected migrateToTime ( integer $time )
$time integer UNIX timestamp value.

migrateToVersion() 보호된 메소드

Migrates to the certain version.
protected migrateToVersion ( string $version )
$version string name in the full format.

migrateUp() 보호된 메소드

Upgrades with the specified migration class.
protected migrateUp ( string $class, $alias ) : boolean
$class string the migration class name
리턴 boolean whether the migration is successful

options() 공개 메소드

public options ( $actionId )

프로퍼티 상세

$db 공개적으로 프로퍼티

the DB connection object or the application component ID of the DB connection.
public $db

$defaultAction 공개적으로 프로퍼티

the default command action.
public $defaultAction

$disableLookup 공개적으로 프로퍼티

lookup all application migration paths
public $disableLookup

$interactive 공개적으로 프로퍼티

whether to execute the migration in an interactive mode.
public $interactive

$migrationLookup 공개적으로 프로퍼티

additional aliases of migration directories
public $migrationLookup

$migrationPath 공개적으로 프로퍼티

the directory storing the migration classes. This can be either a path alias or a directory.
public $migrationPath

$migrationTable 공개적으로 프로퍼티

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

$templateFile 공개적으로 프로퍼티

the template file for generating new migrations. This can be either a path alias (e.g. "@app/migrations/template.php") or a file path.
public $templateFile