Skip to content

Commit

Permalink
use prompt() instead of $sure for migrate/create-all
Browse files Browse the repository at this point in the history
  • Loading branch information
thyseus committed Mar 29, 2017
1 parent 0311983 commit dd9a78b
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions src/controllers/MigrationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,6 @@ class MigrationController extends Controller
*/
public $fixHistory = 0;

/**
* @var bool Are you sure to create migrations for all tables in your database?
*/
public $sure = 'no';

/**
* @inheritdoc
*/
Expand All @@ -138,7 +133,7 @@ public function options($actionID)
return array_merge(
parent::options($actionID),
['defaultDecision', 'migrationPath', 'migrationNamespace', 'db', 'generalSchema', 'templateFile',
'useTablePrefix', 'fixHistory', 'migrationTable', 'sure'],
'useTablePrefix', 'fixHistory', 'migrationTable'],
$actionID === 'update' ? ['migrationNamespaces', 'showOnly', 'templateFileUpdate'] : []
);
}
Expand Down Expand Up @@ -449,12 +444,12 @@ public function actionCreateAll()
return $this->stdout("Your Database does not contain any tables yet.");
}

if ($this->sure !== 'yes') {
return $this->stdout("Please run ./yii migrate/create-all --sure=yes if you want to generate " . count($tables) . " migrations.\n");
}

foreach($tables as $table) {
$this->actionCreate($table);
if ($this->prompt("Are you sure you want to generate " . count($tables) . " migrations? [yes/no]") === 'yes') {
foreach ($tables as $table) {
$this->actionCreate($table);
}
} else {
$this->stdout("Operation cancelled by user\n");
}
}

Expand Down

0 comments on commit dd9a78b

Please sign in to comment.