octicon-rss(16/)
You've already forked yii2
mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-10 02:13:17 +08:00
Fixes #7269: yii\console\controllers\BaseMigrateController now throws exception if directory specified doesn't exist and action isn't create
This commit is contained in:
octicon-git-branch(16/)
octicon-tag(16/)
committed by
Alexander Makarov
gitea-unlock(16/)
parent
6e2e929f7a
commit
a71423cf2a
octicon-diff(16/tw-mr-1) 2 changed files with 6 additions and 2 deletions
@@ -59,7 +59,7 @@ abstract class BaseMigrateController extends Controller
|
||||
* This method is invoked right before an action is to be executed (after all possible filters.)
|
||||
* It checks the existence of the [[migrationPath]].
|
||||
* @param \yii\base\Action $action the action to be executed.
|
||||
* @throws Exception if db component isn't configured
|
||||
* @throws Exception if directory specified in migrationPath doesn't exist and action isn't "create".
|
||||
* @return boolean whether the action should continue to be executed.
|
||||
*/
|
||||
public function beforeAction($action)
|
||||
@@ -67,6 +67,9 @@ abstract class BaseMigrateController extends Controller
|
||||
if (parent::beforeAction($action)) {
|
||||
$path = Yii::getAlias($this->migrationPath);
|
||||
if (!is_dir($path)) {
|
||||
if ($action->id !== 'create') {
|
||||
throw new Exception('Migration failed. Directory specified in migrationPath doesn\'t exist.');
|
||||
}
|
||||
FileHelper::createDirectory($path);
|
||||
}
|
||||
$this->migrationPath = $path;
|
||||
|
||||
Reference in New Issue
Block a user