Skip to content

Commit

Permalink
Allow fallback to standard migration
Browse files Browse the repository at this point in the history
  • Loading branch information
tomchkk committed Mar 10, 2023
1 parent 59a551c commit 547993a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/MigrateCommandExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Database\Console\Migrations\MigrateCommand;
use Illuminate\Database\Migrations\Migrator;
use Illuminate\Support\Collection;
use Netsells\LaravelMutexMigrations\Mutex\DatabaseCacheTableNotFoundException;

class MigrateCommandExtension extends MigrateCommand
{
Expand All @@ -19,7 +20,11 @@ public function __construct(Migrator $migrator, Dispatcher $dispatcher)
public function handle(): int
{
if ($this->option(MutexMigrateCommand::OPTION_MUTEX)) {
return $this->call(MutexMigrateCommand::class, $this->getCommandOptions());
try {
return $this->call(MutexMigrateCommand::class, $this->getCommandOptions());
} catch (DatabaseCacheTableNotFoundException $e) {
$this->components->warn('Falling back to a standard migration');
}
}

return parent::handle();
Expand Down
2 changes: 1 addition & 1 deletion src/MutexMigrateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function handle()
} catch (DatabaseCacheTableNotFoundException $e) {
$this->components->error($e->getMessage());

return self::FAILURE;
throw $e;
} finally {
$this->processor->terminate();
}
Expand Down

0 comments on commit 547993a

Please sign in to comment.