mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 12:54:05 +00:00
* Don't drop tenant databases on `migrate:fresh` if the tenants table doesn't exist * Fix code style (php-cs-fixer) Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
24 lines
564 B
PHP
24 lines
564 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Stancl\Tenancy\Commands;
|
|
|
|
use Illuminate\Database\Console\Migrations\FreshCommand;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
class MigrateFreshOverride extends FreshCommand
|
|
{
|
|
public function handle()
|
|
{
|
|
if (config('tenancy.database.drop_tenant_databases_on_migrate_fresh')) {
|
|
$tenantModel = tenancy()->model();
|
|
|
|
if (Schema::hasTable($tenantModel->getTable())) {
|
|
$tenantModel::cursor()->each->delete();
|
|
}
|
|
}
|
|
|
|
return parent::handle();
|
|
}
|
|
}
|