From b460c2ec203e22b3b49a48146cd8cfaaa7f0bda2 Mon Sep 17 00:00:00 2001 From: Stephen Adamson Date: Fri, 5 Jun 2026 12:12:38 +0100 Subject: [PATCH] fix(scheduling): extend AnonymizeStaleGuestAccounts with additional field scrubbing AnonymizeStaleGuestAccounts now additionally scrubs profile_pic_url (NULL), referral_code (NULL), notes (NULL), and data_retention_consent (FALSE) for stale guest accounts. Previously only scrubbed name, email, phone, and date_of_birth. Ensures comprehensive PII removal for guests with no active/pending bookings and last booking over 6 months old. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- backend/handlers/scheduling/time-blockers.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/backend/handlers/scheduling/time-blockers.go b/backend/handlers/scheduling/time-blockers.go index 1ec1c9a..2bf9107 100644 --- a/backend/handlers/scheduling/time-blockers.go +++ b/backend/handlers/scheduling/time-blockers.go @@ -368,13 +368,17 @@ func CleanupOldReservations(ctx context.Context) error { // Active/pending bookings are excluded so the salon can still contact the guest. func AnonymizeStaleGuestAccounts(ctx context.Context) error { _, err := db.DB.Exec(ctx, ` - UPDATE users SET - n_first_name = 'Guest', - n_last_name = 'Anonymized', - email = 'anon-' || id || '@anon.invalid', - phone = '000000000000', - date_of_birth = '1900-01-01', - updated_at = NOW() + UPDATE users SET + n_first_name = 'Guest', + n_last_name = 'Anonymized', + email = 'anon-' || id || '@anon.invalid', + phone = '000000000000', + date_of_birth = '1900-01-01', + profile_pic_url = NULL, + referral_code = NULL, + notes = NULL, + data_retention_consent = FALSE, + updated_at = NOW() WHERE account_role = 'guest' AND id NOT IN ( SELECT user_id FROM bookings WHERE status IN ('pending', 'confirmed')