Agent Wranglers

Personal data Required

Delete old data automatically

Give each kind of personal data a retention period, and let a scheduled job delete or anonymise rows when it ends.

How to do it

Store the date each row stops being needed, or compute it from a clear column such as last_activity_at. Erasure on request is a separate path, covered by the data requests rule. Run the deletion job daily, in small batches. Remember copies in caches, search indexes, logs and analytics. Backups age out after the period in backup retention. See also keep one retention schedule.

Example

DELETE FROM bookings
WHERE id IN (SELECT id FROM bookings WHERE ends_at < now() - interval '90 days' LIMIT 1000);
-- MySQL refuses LIMIT inside IN, so write it as
DELETE FROM bookings WHERE ends_at < now() - INTERVAL 90 DAY LIMIT 1000;

How to check

Insert a test row dated past its retention period and run the job. The row is gone, and so are its copies in the search index and cache.

For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers data playbook: https://agentwranglers.se/playbook/data/personal-data/retention-jobs.