/**
  * @return string
  */
 public function actionCreate()
 {
     $model = new CreateForm();
     if ($model->load(\Yii::$app->request->post()) and $model->validate()) {
         $params['name'] = $model->name;
         if ($model->path) {
             $params['--migrationPath'] = $model->path;
         }
         return $this->render('index', ['title' => 'Creating migration', 'output' => $this->runMigrationAction('create', $params)]);
     }
     return $this->render('create', compact('model'));
 }
Example #2
0
<div class="panel panel-default">
	<div class="panel-body">
		<?php 
echo $this->render('_buttons');
?>
		<br/>

		<?php 
$form = ActiveForm::begin(['id' => 'create-migration']);
?>

		<div class="row">

			<div class="col-sm-5">
				<?php 
echo $form->field($model, 'path')->dropDownList(CreateForm::getModulesAsArray(), ['prompt' => '--- Application ---', 'autofocus' => true]);
?>
			</div>

			<div class="col-sm-5">
				<?php 
echo $form->field($model, 'name');
?>
			</div>


			<div class="col-sm-2">
				<br/>
				<?php 
echo Html::submitButton('Create', ['class' => 'btn btn-primary']);
?>
 /**
  * @inheritdoc
  */
 protected function getNewMigrations()
 {
     $applied = [];
     foreach ($this->getMigrationHistory(-1) as $migration) {
         $applied[substr($migration['version'], 1, 13)] = true;
     }
     $migrations = $this->getNewMigrationsFromDir($this->migrationPath, $applied);
     $modules = CreateForm::getModulesAsArray();
     foreach ($modules as $moduleMigrationsPath => $moduleId) {
         if (is_dir($moduleMigrationsPath)) {
             $migrations = ArrayHelper::merge($migrations, $this->getNewMigrationsFromDir($moduleMigrationsPath, $applied));
         }
     }
     ksort($migrations);
     return $migrations;
 }