ADD disable foreign key for cleanup command

This commit is contained in:
E98Developer 2026-05-08 06:43:00 +02:00
parent de1eb871b9
commit ab76515822
2 changed files with 39 additions and 33 deletions

View File

@ -115,6 +115,9 @@ public function handle(): int
$this->info('Törlés megkezdése...'); $this->info('Törlés megkezdése...');
\Illuminate\Support\Facades\Schema::disableForeignKeyConstraints();
try {
// Orders törlése // Orders törlése
Order::where('deliveryDate', '<', $date)->delete(); Order::where('deliveryDate', '<', $date)->delete();
$this->info('Megrendelések törölve.'); $this->info('Megrendelések törölve.');
@ -156,6 +159,9 @@ public function handle(): int
$bar->finish(); $bar->finish();
$this->info(""); $this->info("");
$this->info('Archivált megrendelések és kapcsolódó elemek törölve.'); $this->info('Archivált megrendelések és kapcsolódó elemek törölve.');
} finally {
\Illuminate\Support\Facades\Schema::enableForeignKeyConstraints();
}
return 0; return 0;
} }

View File

@ -91,7 +91,7 @@ public function handle(): int
} }
$this->info('Törlés megkezdése...'); $this->info('Törlés megkezdése...');
\Illuminate\Support\Facades\Schema::disableForeignKeyConstraints();
// PriceLists törlése optimalizáltan // PriceLists törlése optimalizáltan
if ($priceListsCount > 0) { if ($priceListsCount > 0) {
$this->info('Árlisták és kapcsolódó árak törlése...'); $this->info('Árlisták és kapcsolódó árak törlése...');
@ -151,7 +151,7 @@ public function handle(): int
} }
$this->info('A tisztítás sikeresen befejeződött.'); $this->info('A tisztítás sikeresen befejeződött.');
\Illuminate\Support\Facades\Schema::enableForeignKeyConstraints();
return 0; return 0;
} }