diff --git a/src/Commands/Migrate.php b/src/Commands/Migrate.php index bbce9d86..3a34ae19 100644 --- a/src/Commands/Migrate.php +++ b/src/Commands/Migrate.php @@ -4,10 +4,10 @@ declare(strict_types=1); namespace Stancl\Tenancy\Commands; -use Exception; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Database\Console\Migrations\MigrateCommand; use Illuminate\Database\Migrations\Migrator; +use Illuminate\Database\QueryException; use Stancl\Tenancy\Concerns\DealsWithMigrations; use Stancl\Tenancy\Concerns\ExtendsLaravelCommand; use Stancl\Tenancy\Concerns\HasATenantsOption; @@ -58,7 +58,7 @@ class Migrate extends MigrateCommand parent::handle(); event(new DatabaseMigrated($tenant)); - } catch (Exception $th) { + } catch (QueryException $th) { if (! $this->option('skip-failing')) { throw $th; } diff --git a/tests/CommandsTest.php b/tests/CommandsTest.php index 3ed34300..3b9f7f3a 100644 --- a/tests/CommandsTest.php +++ b/tests/CommandsTest.php @@ -2,6 +2,7 @@ declare(strict_types=1); +use Illuminate\Database\QueryException; use Illuminate\Support\Facades\DB; use Stancl\Tenancy\Tests\Etc\User; use Stancl\JobPipeline\JobPipeline; @@ -104,9 +105,9 @@ test('migrate command only throws exceptions if skip-failing is not passed', fun Tenant::create(); - expect(fn() => pest()->artisan('tenants:migrate --schema-path="tests/Etc/tenant-schema.dump"'))->toThrow(Exception::class); - expect(fn() => pest()->artisan('tenants:migrate --schema-path="tests/Etc/tenant-schema.dump" --skip-failing'))->not()->toThrow(Exception::class); -})->group('skipfailing'); + expect(fn() => pest()->artisan('tenants:migrate --schema-path="tests/Etc/tenant-schema.dump"'))->toThrow(QueryException::class); + expect(fn() => pest()->artisan('tenants:migrate --schema-path="tests/Etc/tenant-schema.dump" --skip-failing'))->not()->toThrow(QueryException::class); +}); test('dump command works', function () { $tenant = Tenant::create();