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 configuration file.
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 |
array |
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 |
array |
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 |
array |
Example |
// migrate the module 'mymodule' to version 10
Migrate::version(10, 'mymodule', 'module');
|
up($version, $name = 'default', $type = 'app')
The version method will move the migrations up by one, or up to a specific version if given.
Static |
Yes |
Parameters |
Param |
Default |
Description |
$version |
required |
The version you want to migrating up to. If you specify null, it will migrate up to the next 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 |
array |
Example |
// migrate the module 'mymodule' up to version 10
Migrate::up(10, 'mymodule', 'module');
|
down($version, $name = 'default', $type = 'app')
The version method will move the migrations down by one, or down to a specific version if given.
Static |
Yes |
Parameters |
Param |
Default |
Description |
$version |
required |
The version you want to migrating down to. If you specify null, it will migrate down to the next 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 |
array |
Example |
// migrate the module 'mymodule' down to version 10
Migrate::down(10, 'mymodule', 'module');
|
All methods return an array, specifying a list a migration files ( file names only! ) executed.
If no migrations where found, or if the version specified resulted in no migrations being executed, the array returned is empty.