Skip to content

Commit ffb6537

Browse files
authored
Merge pull request #1439 from wajdijurry/fix-bug-1438
Fix Bug #1438
2 parents 1e12d4f + 1ac6f72 commit ffb6537

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

scripts/Phalcon/Migrations.php

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -87,24 +87,26 @@ public static function generate(array $options)
8787
$optionStack->setDefaultOption('noAutoIncrement', null);
8888
$optionStack->setDefaultOption('verbose', false);
8989

90-
$migrationsDirs = $optionStack->getOption('migrationsDir');
90+
$migrationsDir = $migrationsDirs = $optionStack->getOption('migrationsDir');
9191
//select multiple dir
92-
if (count($migrationsDirs) > 1) {
93-
$question = 'Which migrations path would you like to use?' . PHP_EOL;
94-
foreach ($migrationsDirs as $id => $dir) {
95-
$question .= " [{$id}] $dir" . PHP_EOL;
96-
}
97-
fwrite(STDOUT, Color::info($question));
98-
$handle = fopen("php://stdin", "r");
99-
$line = (int)fgets($handle);
100-
if (!isset($migrationsDirs[$line])) {
101-
echo "ABORTING!\n";
102-
return false;
92+
if (is_array($migrationsDirs)) {
93+
if (count($migrationsDirs) > 1) {
94+
$question = 'Which migrations path would you like to use?' . PHP_EOL;
95+
foreach ($migrationsDirs as $id => $dir) {
96+
$question .= " [{$id}] $dir" . PHP_EOL;
97+
}
98+
fwrite(STDOUT, Color::info($question));
99+
$handle = fopen("php://stdin", "r");
100+
$line = (int)fgets($handle);
101+
if (!isset($migrationsDirs[$line])) {
102+
echo "ABORTING!\n";
103+
return false;
104+
}
105+
fclose($handle);
106+
$migrationsDir = $migrationsDirs[$line];
107+
} else {
108+
$migrationsDir = $migrationsDirs[0];
103109
}
104-
fclose($handle);
105-
$migrationsDir = $migrationsDirs[$line];
106-
} else {
107-
$migrationsDir = $migrationsDirs[0];
108110
}
109111
// Migrations directory
110112
if ($migrationsDir && !file_exists($migrationsDir)) {

0 commit comments

Comments
 (0)