mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 19:04:02 +00:00
Only delete tenants in MigrateFreshOverride if the tenants table exists (#1007)
* 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>
This commit is contained in:
parent
1db2f0913f
commit
9520cbc811
1 changed files with 6 additions and 1 deletions
|
|
@ -5,13 +5,18 @@ declare(strict_types=1);
|
||||||
namespace Stancl\Tenancy\Commands;
|
namespace Stancl\Tenancy\Commands;
|
||||||
|
|
||||||
use Illuminate\Database\Console\Migrations\FreshCommand;
|
use Illuminate\Database\Console\Migrations\FreshCommand;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
class MigrateFreshOverride extends FreshCommand
|
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