Skip to content

Commit e17d680

Browse files
authored
Create pruning-workflows.md
1 parent bbfbfca commit e17d680

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

Diff for: docs/configuration/pruning-workflows.md

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
sidebar_position: 6
3+
---
4+
5+
# Pruning Workflows
6+
Sometimes you may want to periodically delete completed workflows that are no longer needed. To accomplish this, you may use the `model:prune` artisan command.
7+
8+
```bash
9+
php artisan model:prune --model="Workflow\Models\StoredWorkflow"
10+
```
11+
12+
By default, only completed workflows older than 1 month are pruned. You can control this via configuration setting.
13+
14+
```php
15+
'prune_age' => '1 month',
16+
```
17+
18+
You can schedule the `model:prune` artisan command in your application's `routes/console.php` file.
19+
20+
```php
21+
Schedule::command('model:prune', [
22+
'--model' => StoredWorkflow::class,
23+
])->daily();
24+
```
25+
26+
You can also control which workflows are pruned by extending the base workflow model and implementing your own `prunable` method.
27+
28+
```php
29+
public function prunable(): Builder
30+
{
31+
//
32+
}
33+
```
34+
35+
You may test the `model:prune` command with the `--pretend` option. When pretending, the `model:prune` command will report how many records would be pruned if the command were to actually run.
36+
37+
```bash
38+
php artisan model:prune --model="Workflow\Models\StoredWorkflow" --pretend
39+
```

0 commit comments

Comments
 (0)