laravel-pruning-fires-delete-events
Narrow trigger extracted from skills/laravel-conventions §3.13–§3.14, so a retention/pruning sweep
routes here directly instead of only through the whole Laravel block.
When
Writing or reviewing a scheduled sweep, a Prunable-style mass deletion, or any code purging rows
past a retention window on a model that uses soft deletes.
Steps
Every model using soft deletes also carries a pruning policy with a retention window. Soft
deletes without pruning is an unbounded table silently becoming the biggest one in the database.
Pruning is deleting, and a sweep fires the same per-row events as a delete. The framework's
per-model prune trait loads the rows in chunks, calls the model's pruning() hook, then delete() (or
forceDelete() for a soft-deleting model), so the deleting and deleted events fire. Its mass variant runs
chunked delete queries instead: no pruning() hook and no deleting or deleted events (documented). The
same bypass comes from event muting, a quiet delete, a builder-level delete(), a table truncate, or a
hand-rolled DELETE ... WHERE created_at < cron.
"This data is never deleted, only pruned" is a contradiction. If a row can be purged after a
retention window, it is deletable — the window only says when.
Pruning a soft-deleting model removes rows for good. A row matching the prunable query is force
deleted, trashed or not (documented), which is the point of step 1 and also why the retention window must be
chosen on purpose. model:prune --pretend reports how many rows would go without deleting them.
Output / checkpoint
The sweep goes through the model's normal delete path (row by row, or a mechanism that still fires
per-row lifecycle events), never a bulk statement or a suppressed-event mass delete.
Guardrails
- This is the retention-side twin of
laravel-no-cascade-delete — the same bypass (rows leave, no
event fires, nothing downstream hears) arriving from the scheduled-sweep direction instead of the
foreign-key direction.
- The full schema section, including why "shared shape" or "shared screen" is never the reason two
concepts merge into one model, lives in
skills/laravel-conventions §3.
Origin
Extracted from skills/laravel-conventions §3.13–§3.14 (2026-09-09). Facts checked on 2026-10-20 against the
framework's Eloquent documentation, 12.x (Deleting Models: mass deletes dispatch no model events; Pruning Models,
Mass Pruning; Events, Muting Events; read for facts, our words) and the framework source (MIT, LICENSE read):
Prunable.php (pruneAll, prune) and MassPrunable.php (pruneAll). Steps 1 and 3 and the house rule
against the mass variant are our own policy, not a framework statement: the framework offers the mass trait and
documents its trade-off.
Independent verification 2026-10-21: 9 checked, 9 matched, 0 corrected, 0 unverified.
1---2name: laravel-pruning-fires-delete-events3description: "Use when writing or reviewing a pruning/retention sweep on a soft-deleted model: never a mass-prune trait, event suppression, a quiet delete, or a raw DELETE — pruning is deleting, it fires the same per-row events."4metadata:5 source: https://skillmd.com/skills/techmefr/laravel-pruning-fires-delete-events6---78# laravel-pruning-fires-delete-events910Narrow trigger extracted from `skills/laravel-conventions` §3.13–§3.14, so a retention/pruning sweep11routes here directly instead of only through the whole Laravel block.1213## When14Writing or reviewing a scheduled sweep, a `Prunable`-style mass deletion, or any code purging rows15past a retention window on a model that uses soft deletes.1617## Steps181. **Every model using soft deletes also carries a pruning policy with a retention window.** Soft19 deletes without pruning is an unbounded table silently becoming the biggest one in the database.202. **Pruning is deleting, and a sweep fires the same per-row events as a delete.** The framework's21 per-model prune trait loads the rows in chunks, calls the model's `pruning()` hook, then `delete()` (or22 `forceDelete()` for a soft-deleting model), so the deleting and deleted events fire. Its mass variant runs23 chunked delete queries instead: no `pruning()` hook and no deleting or deleted events (documented). The24 same bypass comes from event muting, a quiet delete, a builder-level `delete()`, a table truncate, or a25 hand-rolled `DELETE ... WHERE created_at <` cron.263. **"This data is never deleted, only pruned" is a contradiction.** If a row can be purged after a27 retention window, it is deletable — the window only says when.28294. **Pruning a soft-deleting model removes rows for good.** A row matching the prunable query is force30 deleted, trashed or not (documented), which is the point of step 1 and also why the retention window must be31 chosen on purpose. `model:prune --pretend` reports how many rows would go without deleting them.3233## Output / checkpoint34The sweep goes through the model's normal delete path (row by row, or a mechanism that still fires35per-row lifecycle events), never a bulk statement or a suppressed-event mass delete.3637## Guardrails38- This is the retention-side twin of `laravel-no-cascade-delete` — the same bypass (rows leave, no39 event fires, nothing downstream hears) arriving from the scheduled-sweep direction instead of the40 foreign-key direction.41- The full schema section, including why "shared shape" or "shared screen" is never the reason two42 concepts merge into one model, lives in `skills/laravel-conventions` §3.4344## Origin45Extracted from `skills/laravel-conventions` §3.13–§3.14 (2026-09-09). Facts checked on 2026-10-20 against the46framework's Eloquent documentation, 12.x (Deleting Models: mass deletes dispatch no model events; Pruning Models,47Mass Pruning; Events, Muting Events; read for facts, our words) and the framework source (MIT, LICENSE read):48`Prunable.php` (`pruneAll`, `prune`) and `MassPrunable.php` (`pruneAll`). Steps 1 and 3 and the house rule49against the mass variant are our own policy, not a framework statement: the framework offers the mass trait and50documents its trade-off.5152Independent verification 2026-10-21: 9 checked, 9 matched, 0 corrected, 0 unverified.