/** * 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. * @return boolean whether the action should continue to be executed. */ public function beforeAction($action) { if (parent::beforeAction($action)) { if ($action->id !== 'create') { $this->db = Instance::ensure($this->db, Connection::className()); Schema::setDb($this->db); } return true; } else { return false; } }