1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 13:14:05 +00:00

Don't drop tenant databases on migrate:fresh if the tenants table doesn't exist

This commit is contained in:
lukinovec 2022-11-18 09:50:50 +01:00 committed by GitHub
parent 1db2f0913f
commit 504d02354a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Stancl\Tenancy\Commands;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Console\Migrations\FreshCommand;
class MigrateFreshOverride extends FreshCommand
@ -11,7 +12,11 @@ class MigrateFreshOverride extends FreshCommand
public function handle()
{
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();