From 134db76b341b7e69a57a833956c8fd6857882206 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Mon, 22 Apr 2024 15:16:47 +0200 Subject: [PATCH] [11.x] Reset connection after migrate for FreshCommand (#51167) * Reset connection after migrate * wip --- .../Console/Migrations/FreshCommand.php | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/Illuminate/Database/Console/Migrations/FreshCommand.php b/src/Illuminate/Database/Console/Migrations/FreshCommand.php index fb33f6542d3a..de43e74f8610 100644 --- a/src/Illuminate/Database/Console/Migrations/FreshCommand.php +++ b/src/Illuminate/Database/Console/Migrations/FreshCommand.php @@ -62,20 +62,18 @@ public function handle() $database = $this->input->getOption('database'); - if (! is_null($database)) { - $this->migrator->setConnection($database); - } - - if ($this->migrator->repositoryExists()) { - $this->newLine(); - - $this->components->task('Dropping all tables', fn () => $this->callSilent('db:wipe', array_filter([ - '--database' => $database, - '--drop-views' => $this->option('drop-views'), - '--drop-types' => $this->option('drop-types'), - '--force' => true, - ])) == 0); - } + $this->migrator->usingConnection($database, function () use ($database) { + if ($this->migrator->repositoryExists()) { + $this->newLine(); + + $this->components->task('Dropping all tables', fn () => $this->callSilent('db:wipe', array_filter([ + '--database' => $database, + '--drop-views' => $this->option('drop-views'), + '--drop-types' => $this->option('drop-types'), + '--force' => true, + ])) == 0); + } + }); $this->newLine();