console\controllers\MigrateController::actionCreate PHP Метод

actionCreate() публичный Метод

This command creates a new migration using the available migration template. After using this command, developers should modify the created migration skeleton by filling up the actual migration logic. ~~~ yii migrate/create create_user_table ~~~
public actionCreate ( string $name )
$name string the name of the new migration. This should only contain letters, digits and/or underscores.
    public function actionCreate($name)
    {
        if (!preg_match('/^\\w+$/', $name)) {
            throw new Exception("The migration name should contain letters, digits and/or underscore characters only.");
        }
        $name = 'm' . gmdate('ymd_His') . '_' . $name;
        $file = Yii::getAlias($this->migrationPath) . DIRECTORY_SEPARATOR . $name . '.php';
        if ($this->confirm("Create new migration '{$file}'?")) {
            $content = $this->renderFile(Yii::getAlias($this->templateFile), ['className' => $name]);
            file_put_contents(Yii::getAlias($file), $content);
            echo "New migration created successfully.\n";
        }
    }