Commit 50220cc9 by Carsten Brandt

Merge PR #3421 branch 'migrate-command-enhancement' of https://github.com/creocoder/yii2

* 'migrate-command-enhancement' of https://github.com/creocoder/yii2: MigrateController refactoring CHANGELOG fixed Comments updated CHANGELOG updated MigrateCommand enhancement. `all` option added for `down` action. Conflicts: framework/CHANGELOG.md
parents 514efb99 f5b7788e
...@@ -52,6 +52,7 @@ Yii Framework 2 Change Log ...@@ -52,6 +52,7 @@ Yii Framework 2 Change Log
- Enh: Added `yii\console\Controller::EXIT_CODE_NORMAL` and `yii\console\Controller::EXIT_CODE_ERROR` constants (samdark) - Enh: Added `yii\console\Controller::EXIT_CODE_NORMAL` and `yii\console\Controller::EXIT_CODE_ERROR` constants (samdark)
- Enh: `yii\console\MigrateController` now returns `yii\console\Controller::EXIT_CODE_ERROR` in case of failed migration (samdark) - Enh: `yii\console\MigrateController` now returns `yii\console\Controller::EXIT_CODE_ERROR` in case of failed migration (samdark)
- Enh: Added method ErrorHandler::unregister() for unregistering the ErrorHandler (cebe) - Enh: Added method ErrorHandler::unregister() for unregistering the ErrorHandler (cebe)
- Enh: Added `all` option to `MigrateController::actionDown()` action (creocoder, umneeq)
- Chg #2913: RBAC `DbManager` is now initialized via migration (samdark) - Chg #2913: RBAC `DbManager` is now initialized via migration (samdark)
- Chg #3036: Upgraded Twitter Bootstrap to 3.1.x (qiangxue) - Chg #3036: Upgraded Twitter Bootstrap to 3.1.x (qiangxue)
- Chg #3175: InvalidCallException, InvalidParamException, UnknownMethodException are now extended from SPL BadMethodCallException (samdark) - Chg #3175: InvalidCallException, InvalidParamException, UnknownMethodException are now extended from SPL BadMethodCallException (samdark)
......
...@@ -193,6 +193,7 @@ class MigrateController extends Controller ...@@ -193,6 +193,7 @@ class MigrateController extends Controller
* ~~~ * ~~~
* yii migrate/down # revert the last migration * yii migrate/down # revert the last migration
* yii migrate/down 3 # revert the last 3 migrations * yii migrate/down 3 # revert the last 3 migrations
* yii migrate/down all # revert all migrations
* ~~~ * ~~~
* *
* @param integer $limit the number of migrations to be reverted. Defaults to 1, * @param integer $limit the number of migrations to be reverted. Defaults to 1,
...@@ -203,9 +204,13 @@ class MigrateController extends Controller ...@@ -203,9 +204,13 @@ class MigrateController extends Controller
*/ */
public function actionDown($limit = 1) public function actionDown($limit = 1)
{ {
$limit = (int) $limit; if ($limit === 'all') {
if ($limit < 1) { $limit = null;
throw new Exception("The step argument must be greater than 0."); } else {
$limit = (int) $limit;
if ($limit < 1) {
throw new Exception("The step argument must be greater than 0.");
}
} }
$migrations = $this->getMigrationHistory($limit); $migrations = $this->getMigrationHistory($limit);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment