yii\console\controllers\MigrateController::createMigration PHP Method

createMigration() protected method

Creates a new migration instance.
protected createMigration ( string $class ) : Migration
$class string the migration class name
return yii\db\Migration the migration instance
    protected function createMigration($class)
    {
        $class = trim($class, '\\');
        if (strpos($class, '\\') === false) {
            $file = $this->migrationPath . DIRECTORY_SEPARATOR . $class . '.php';
            require_once $file;
        }
        return new $class(['db' => $this->db]);
    }

Usage Example

 /**
  * Creates a new migration instance.
  * @param string $class the migration class name
  * @return \yii\db\MigrationInterface the migration instance
  */
 protected function createMigration($class)
 {
     if ($this->includeModuleMigrations) {
         $this->migrationPath = $this->getMigrationPath($class);
     }
     return parent::createMigration($class);
 }