Skip to content

Commit

Permalink
fix(inputToArtisanOptions): Correct parsing non-bool options.
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Rogers committed Apr 5, 2019
1 parent 9690bd4 commit eeefcec
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Handlers/MigrateStartingHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ public function handle(CommandStarting $event)
// Must pass along options or it may use wrong DB or have
// inconsistent output.
$options = self::inputToArtisanOptions($event->input);
$database = $options['--database'] ?? env('DB_CONNECTION');
$db_driver = \DB::connection($database)->getDriverName();
$database = $options['--database'] ?? \DB::getConfig('name');
$db_driver = \DB::getDriverName();
if (! in_array($db_driver, MigrateDumpCommand::SUPPORTED_DB_DRIVERS, true)) {
// CONSIDER: Logging or emitting console warning.
return;
Expand All @@ -79,13 +79,13 @@ public function handle(CommandStarting $event)
// Try-catch instead of information_schema since not all have one.
try {
$has_migrated_any = ! is_null(
\DB::connection($database)->table('migrations')->value('id')
\DB::table('migrations')->value('id')
);
} catch (\PDOException $e) {
// No op. when table does not exist.
if (
! in_array($e->getCode(), ['42P01', '42S02'], true)
&& ! preg_match("/\bdoes ?n[o']t exist\b/iu", $e->getMessage())
&& ! preg_match("/\b(does ?n[o']t exist|no such table)\b/iu", $e->getMessage())
) {
throw $e;
}
Expand All @@ -112,7 +112,7 @@ public static function inputToArtisanOptions(InputInterface $input) : array
if (false !== $input->getParameterOption($option)) {
$options[$option] = true;
}
} else {
} elseif (false !== $input->getParameterOption($option)) {
$options[$option] = $input->getParameterOption($option);
}
}
Expand Down

0 comments on commit eeefcec

Please sign in to comment.