Refactor database cleanup command to include dry-run mode

This commit is contained in:
Andras Bacsai 2024-03-12 10:57:07 +01:00
parent b576014d07
commit 6ef79f5213

View File

@ -12,9 +12,13 @@ class CleanupDatabase extends Command
public function handle()
{
echo "Running database cleanup...\n";
if ($this->option('yes')) {
echo "Running database cleanup...\n";
} else {
echo "Running database cleanup in dry-run mode...\n";
}
$keep_days = 60;
echo "Keep days: $keep_days\n";
// Cleanup failed jobs table
$failed_jobs = DB::table('failed_jobs')->where('failed_at', '<', now()->subDays(7));
$count = $failed_jobs->count();