You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fixup! feat: add prune_db command to prune old checkouts, builds and tests. * Delete rows older than a given age with manual cascade (checkout -> builds -> tests) * --origins scoping, --dry-run and a --yes confirmation. Extract parse_interval into a shared helper and add integration tests.
* Add tables parameter.
* Protect issue related rows by default, and add parameter to
bypass.
Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
The `prune_db` command deletes old rows from `checkouts`, `builds`, and `tests` in the dashboard database. It is intended for routine retention: run with `--dry-run` first, review the counts, then execute without `--dry-run`.
4
+
5
+
Models use `DO_NOTHING` foreign keys, so the command applies manual cascade rules instead of relying on the database:
6
+
7
+
- An old checkout also removes its builds and tests, even when those children are newer than the cutoff.
8
+
- An old build also removes its tests, even when they are newer than the cutoff.
9
+
10
+
## Parameters
11
+
12
+
### Required Parameters
13
+
14
+
-`--older-than`: Delete rows older than this age. Format: `'x days'`, `'x hours'`, or `'x minutes'` (for example, `'30 days'`).
15
+
16
+
### Optional Parameters
17
+
18
+
-`--tables`: Limit pruning to specific tables (comma-separated). Valid options: `checkouts`, `builds`, `tests`. Default: all three.
19
+
- Cascade still applies inside the selected tables: a build matched because its checkout is old is deleted when `builds` is selected, and a test matched because its build is doomed is deleted when `tests` is selected.
20
+
- Tables not listed are not deleted. For example, `--tables builds` removes old builds but leaves their tests in place. Selecting a parent without its children (e.g. only `checkouts`) can therefore leave orphaned rows.
21
+
-`--origins`: Limit age-based pruning to specific origins (comma-separated). If omitted, any origin is considered.
22
+
- Cascade ignores origin: once a parent row is doomed, its children are removed even if they belong to a different origin.
23
+
-`--batch-size`: Number of rows deleted per batch (default: `10000`). Must be at least `1`.
24
+
-`--skip-issue-protection`: Prune builds and tests linked to issues. By default, rows with an associated incident are kept.
25
+
-`--dry-run`: Print counts without deleting anything.
26
+
-`--yes`: Skip the confirmation prompt and delete immediately.
If those tables must stay consistent, plan separate cleanup or accept stale references until another process removes them.
69
+
70
+
## Recommended Workflow
71
+
72
+
1. Run with `--dry-run` and review per-table counts.
73
+
2. Add `--origins` when retention should apply to specific origins only.
74
+
3. Use `--tables` only when you intentionally want a partial prune.
75
+
4. Run without `--dry-run`; confirm at the prompt unless `--yes` is set.
76
+
77
+
## Notes
78
+
79
+
- Deletion is batched and child-first (`tests`, then `builds`, then `checkouts`) to avoid orphans within the pruned set.
80
+
- Each batch commits separately to keep locks short.
81
+
-`--origins` scopes the age filter only. Cascade deletions do not re-check the child's origin.
82
+
- By default, builds and tests referenced by `incidents` are not pruned, and their parent checkouts are kept too. Use `--skip-issue-protection` to delete them anyway (incident rows are not removed by this command).
0 commit comments