I'm attempting a simple daily model prune as my first scheduled task. The site is in deployment with Forge. Unfortunately, the scheduled daily task is not being executed in production. Was wondering if I may be missing a step. I've followed docs as closely as possible. Code below for review.
Any idea as to why this isn't running? Thanks!
class Event extends Model
{
use HasFactory, Prunable;
public function prunable()
{
return static::where('date', '<', now()->subDay());
}
}
// app/Console/Kernel.php
protected function schedule(Schedule $schedule)
{
$schedule->command('model:prune')->daily();
}
And when I SSH into Forge server CLI
$ php artisan model:prune --pretend
3 [App\Models\Event] records will be pruned.
$ php artisan model:prune
3 [App\Models\Event] records have been pruned.
The 3 models above should have been pruned overnight but weren't.