yii\console\controllers\BaseMigrateController::actionCreate PHP Method

actionCreate() public method

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 In order to generate a namespaced migration, you should specify a namespace before the migration's name. Note that backslash (\) is usually considered a special character in the shell, so you need to escape it properly to avoid shell errors or incorrect behavior. For example: yii migrate/create 'app\\migrations\\createUserTable' In case [[migrationPath]] is not set and no namespace is provided, the first entry of [[migrationNamespaces]] will be used.
public actionCreate ( string $name )
$name string the name of the new migration. This should only contain letters, digits, underscores and/or backslashes. Note: If the migration name is of a special form, for example create_xxx or drop_xxx, then the generated migration file will contain extra code, in this case for creating/dropping tables.
    public function actionCreate($name)
    {
        if (!preg_match('/^[\\w\\\\]+$/', $name)) {
            throw new Exception('The migration name should contain letters, digits, underscore and/or backslash characters only.');
        }
        list($namespace, $className) = $this->generateClassName($name);
        $migrationPath = $this->findMigrationPath($namespace);
        $file = $migrationPath . DIRECTORY_SEPARATOR . $className . '.php';
        if ($this->confirm("Create new migration '{$file}'?")) {
            $content = $this->generateMigrationSourceCode(['name' => $name, 'className' => $className, 'namespace' => $namespace]);
            FileHelper::createDirectory($migrationPath);
            file_put_contents($file, $content);
            $this->stdout("New migration created successfully.\n", Console::FG_GREEN);
        }
    }