Database Maintenance
Pruning old runs, repacking SQLite databases, and migrating legacy JSONL logs.
Commands for managing the local SQLite historical database (history.db), purging stale run records, reclaiming storage space, and migrating legacy logs.
Cleaning History (zr history clean)
Purges historical test records from history.db based on count or age thresholds.
# Keep only the most recent 100 runsnpx zr history clean --keep 100
# Remove runs older than 30 daysnpx zr history clean --older-than 30d
# Dry-run preview: see what would be deleted without modifying datanpx zr history clean --older-than 60d --dry-runClean Options
| Option | Description |
|---|---|
--keep <N> |
Number of most recent test runs to retain. |
--older-than <period> |
Retention duration. Accepts days (30d), weeks (4w), or months (3m). |
--dry-run |
Preview the number of runs and attachment references to be deleted without writing changes. |
--force |
Skip interactive confirmation prompts in TTY sessions. |
Repacking Database (zr history vacuum)
Runs an aggressive SQLite VACUUM command to reclaim unused disk space, defragment pages, and rebuild database indices after deleting historical runs.
npx zr history vacuumPrints the size of history.db before and after optimization and the total bytes reclaimed.
Migrating Legacy Logs (zr history migrate)
Converts legacy raw execution logs (history.jsonl or directory dumps) into the indexed SQLite history.db schema:
npx zr history migrate- Scans
zen-report/for legacy JSON/JSONL runs. - Backs up existing databases before migration.
- Verifies record checksums and idempotency keys to prevent duplicate runs.