mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 17:14:03 +00:00
Don't drop tenant databases on migrate:fresh if the tenants table doesn't exist
This commit is contained in:
parent
1db2f0913f
commit
504d02354a
1 changed files with 6 additions and 1 deletions
|
|
@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Stancl\Tenancy\Commands;
|
namespace Stancl\Tenancy\Commands;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
use Illuminate\Database\Console\Migrations\FreshCommand;
|
use Illuminate\Database\Console\Migrations\FreshCommand;
|
||||||
|
|
||||||
class MigrateFreshOverride extends FreshCommand
|
class MigrateFreshOverride extends FreshCommand
|
||||||
|
|
@ -11,7 +12,11 @@ class MigrateFreshOverride extends FreshCommand
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
if (config('tenancy.database.drop_tenant_databases_on_migrate_fresh')) {
|
if (config('tenancy.database.drop_tenant_databases_on_migrate_fresh')) {
|
||||||
tenancy()->model()::cursor()->each->delete();
|
$tenantModel = tenancy()->model();
|
||||||
|
|
||||||
|
if (Schema::hasTable($tenantModel->getTable())) {
|
||||||
|
$tenantModel::cursor()->each->delete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::handle();
|
return parent::handle();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue