DAT-31Required
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
Anonymised means nobody can single out, link or infer a person from what is left, even with other data. Blanking the name column usually only pseudonymises, and pseudonymised data stays personal data. When in doubt, delete the row or keep only counts without IDs. 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.
Examples
SQL 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. An anonymised row keeps no ID, email, address or free text that links it to the person.
Sources
- GDPR Article 5 on principles of processing
- Article 29 Working Party Opinion 05/2014 on Anonymisation Techniques
Related rules
- DAT-76 Keep the history of records that settle disputes in Data and databases
- WEB-217 Let people see and delete their data in Website
- OPS-46 Keep backups for a set time in Operations and observability
- CMP-11 Keep one retention schedule in Compliance and governance
- DAT-79 Pause deletion for records under a legal hold in Data and databases
- DAT-72 Delete every copy of a tenant when the contract ends in Data and databases
- PAY-56 Keep payment records for the legal period in Payments and billing
- AIF-48 Keep prompt and answer text briefly and apart in AI features
- ACC-57 Warn before closing inactive accounts in Accounts and identity
- CMP-66 Check traders before they sell on your marketplace in Compliance and governance
- NTF-35 Delete old inbox items on a schedule in Notifications
- SCL-26 Move finished rows out of hot tables in Scaling
- MOB-1 Give reviewers a working demo account in Mobile apps
- MOB-24 Encrypt local data that holds personal data in Mobile apps
- DEN-9 Carry deletes into the warehouse in Data engineering
- DEN-25 Erase people from the warehouse within the month in Data engineering
- ECM-42 Let each seller reach only their own orders and customers in E-commerce and fulfilment
- IOT-8 Factory reset erases every owner's data and keys in Connected devices
- IOT-31 List every sensor and every field that leaves the device in Connected devices
- ANA-10 Delete raw events on a schedule in Product analytics and experiments
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/data/personal-data/retention-jobs">Agent Wranglers data and databases playbook</a>. In code you write, add a comment next to it with the same link.