Without an active retention policy, audit log tables grow without bound. Every model create, update, and delete appends a new row, and in high-traffic applications those rows can accumulate into millions of records over time — inflating storage costs, degrading query performance, and making manual cleanup painful. ModelScribe’s prune command gives you a single, schedulable entry point that enforces your retention rules and reports exactly how many records were removed.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/HypathStack/model-scribe/llms.txt
Use this file to discover all available pages before exploring further.
How pruning works
When you runmodel-scribe:prune, the command calls ModelScribe::prune() on the application’s ModelScribe instance, which in turn delegates to the configured driver’s own prune() method. Each driver knows how to clean up its own storage, so the command itself stays thin:
Running the command
Pruning programmatically
You can invoke pruning from your own code — for example inside a custom Artisan command, a job, or a maintenance script — using theModelScribe facade:
How each driver handles pruning
database
The database driver is the only driver that actively deletes records. When prune() is called it first collects every table it manages — the default model_scribe_logs table plus every table referenced by named stores under drivers.database.stores — and then applies your configured retention rule to each one:
| Retention type | Behaviour |
|---|---|
permanent | No records are deleted. Returns 0. |
days | Deletes all rows whose created_at is older than the configured days value. |
rotating | Keeps only the latest keep records across the entire table and deletes the rest. |
The
rotating retention type keeps the latest keep records across the whole table, not per subject or per model. If you have 500 App\Models\Invoice records and 500 App\Models\Order records in the same table and keep is set to 500, half of those records will be pruned regardless of which model they belong to.file
The file driver is a no-op — prune() always returns 0. File rotation (size-based splitting, log archiving, and deletion of old files) is handled entirely by Laravel’s built-in logging system via the daily or single channel you configure. There is nothing for ModelScribe to manage on top of that.
stack
The stack driver calls prune() on each of its configured sub-drivers in turn and returns the sum of their individual counts. If your stack contains both a database and a file driver, you get back the number of database rows deleted (since the file driver always returns 0).
Scheduling daily pruning
Add the prune command to your scheduler inroutes/console.php so old records are cleaned up automatically:
03:00) minimises lock contention on the audit table. On very large tables you may want to combine a days-based policy with a nightly schedule rather than rotating, which issues a single bulk DELETE that could be expensive on tables with tens of millions of rows.
For full details on configuring retention types and values, see the Retention configuration reference.