-
Database
Add a periodic data integrity audit
Runs scheduled consistency checks (orphans, bad states, drift) so data problems surface before users find them.
Free Prompt
Build a scheduled data integrity audit for my app: a recurring job that checks the consistency rules my data should always satisfy and reports violations.
Define checks from my actual invariants: no orphaned records (line items pointing at missing orders, posts pointing at deleted users); no impossible states (orders marked paid with no payment record, subscriptions active past their cancel date, negative balances or inventory); no drift in denormalized values (cached counts that don't match the real count, totals that don't equal the sum of their line items); and required relationships intact (every user has the profile or settings record the app assumes exists). Run the audit daily or weekly in read-only mode, log each violation with the record IDs, and alert me when violations appear. Where a violation is mechanically fixable, offer a dry-run repair script, never an auto-fix that mutates data unreviewed.
Keep the checks cheap: run them in batches with limits so the audit itself never becomes the load problem. Don't duplicate checks the database enforces with constraints; this job catches what constraints can't.
Deliver: the invariant list per model, the scheduled job, the alerting, the repair scripts in dry-run mode, and verification: deliberately create a violation (an orphaned line item, a drifting count) and confirm the next run reports it.
What This Does / How This Helps
Adds a recurring job that checks your data against the rules it should always satisfy, and alerts you when reality disagrees. Data corruption accumulates silently: a failed deploy leaves orphans, a race drifts a counter, a manual fix forgets a related record. Users find these before you do, usually at the worst moment. The audit job inverts that: you get a report of the orphans and impossible states while they're still small. The repair scripts stay dry-run only, because an auto-fixer with its own bug is worse than the corruption it was cleaning.
Want to skip doing this by hand?
Fortivibe audits your app for all of the areas these prompts cover (and more).