Migrate クラス

The migrate class allows you to run, walk through and revert Migrations from your controllers. Migrations are supported in the application, in modules and in packages.

current($name = 'default', $type = 'app')

Migrates to the current schema set in the migration config.

Static Yes
パラメータ
パラメータ 規定値 説明
$name
'default'
Name of the package or module. In case of app, 'default' is used.
$type
'app'
Type of migration. Valid values are 'app', 'module' and 'package'.
返り値 bool
// run the migrations of the application, up to the current schema.
Migrate::current('default', 'app');

latest($name = 'default', $type = 'app')

Migrates to the latest schema set in the migration config.

Static Yes
パラメータ
パラメータ 規定値 説明
$name
'default'
Name of the package or module. In case of app, 'default' is used.
$type
'app'
Type of migration. Valid values are 'app', 'module' and 'package'.
返り値 bool
// run the migrations of the 'mypackage' package, up to the latest schema.
Migrate::latest('mypackage', 'package');

version($version, $name = 'default', $type = 'app')

The version method will move the migrations up or down to set the schema at a specific migration version.

Static Yes
パラメータ
パラメータ 規定値 説明
$version 必須 The version you are migrating to. If you specify null, it will migrate to the latest version.
$name
'default'
Name of the package or module. In case of app, 'default' is used.
$type
'app'
Type of migration. Valid values are 'app', 'module' and 'package'.
返り値 mixed - The number of the version migrated to, or false in case the requested version was the current version.
// migrate the module 'mymodule' to version 10
Migrate::version(10, 'mymodule', 'module');