Migrate Class

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
Parameters
Param Default Description
$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'.
Returns bool
Example
// 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
Parameters
Param Default Description
$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'.
Returns bool
Example
// 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
Parameters
Param Default Description
$version required 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'.
Returns mixed - The number of the version migrated to, or false in case the requested version was the current version.
Example
// migrate the module 'mymodule' to version 10
Migrate::version(10, 'mymodule', 'module');