mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-13 22:06:51 +08:00
Fixes #14864: Ability to use dependencies in constructor of migrations
This commit is contained in:

committed by
Alexander Makarov

parent
7ff12aac42
commit
ab8c54f12a
@ -14,6 +14,7 @@ use yii\base\NotSupportedException;
|
||||
use yii\console\Controller;
|
||||
use yii\console\Exception;
|
||||
use yii\console\ExitCode;
|
||||
use yii\db\MigrationInterface;
|
||||
use yii\helpers\Console;
|
||||
use yii\helpers\FileHelper;
|
||||
|
||||
@ -760,10 +761,13 @@ abstract class BaseMigrateController extends Controller
|
||||
protected function createMigration($class)
|
||||
{
|
||||
$this->includeMigrationFile($class);
|
||||
$migration = new $class();
|
||||
|
||||
/** @var MigrationInterface $migration */
|
||||
$migration = Yii::createObject($class);
|
||||
if ($migration instanceof BaseObject && $migration->canSetProperty('compact')) {
|
||||
$migration->compact = $this->compact;
|
||||
}
|
||||
|
||||
return $migration;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user