chore(scripts): dry-run-first staging test-account purge (BUNYIP-273) #336
Loading…
Reference in a new issue
No description provided.
Delete branch "chore/BUNYIP-273-purge-test-accounts"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Adds
scripts/purge-staging-test-accounts.shto clear the ~400 accumulated seeded / manual test accounts from a non-production bunyip database (BUNYIP-273). Since BUNYIP-273 is destructive and needs staging DB access, this is an operator-run tool rather than an automated job.Why a script and not the admin endpoint
DELETE /admin/users/{id}is a soft delete (UserRepository::soft_delete). That leaves soft-delete residue and eventually collides with the BUNYIP-161 partial unique index on(email) WHERE deleted_at IS NULL. The script instead mirrors the supported hard-delete path (UserRepository::clear_deps_and_delete_users, the BUNYIP-246 semantics) statement for statement: clearaudit_logs.actor_idandadmin_notifications(user_id+read_by), thenDELETE FROM users, letting FK cascades remove the rest. It touches no encryption keys, so it cannot orphan retained encrypted data (the rotation risk called out in the issue).Safety model
--commit.--patternis required (a raw SQL LIKE againstusers.email) and has no default, so a bare run can never match everything.role = 'admin'rows are always excluded.--commitadditionally requires--i-know-this-is-not-prodand a typed confirmation phrase.Usage
Satisfies the hard-delete / no-residue / no-key-rotation acceptance criteria. The optional "recurring purge / naming convention" AC is left as a follow-up.
#BUNYIP-273
Adds scripts/purge-staging-test-accounts.sh to hard-delete accumulated seeded/manual test accounts from a non-production bunyip database. The admin DELETE /admin/users/{id} endpoint is a soft delete, which leaves residue and eventually clashes with the BUNYIP-161 partial unique index; this script instead mirrors the supported BUNYIP-246 hard-delete path (UserRepository::clear_deps_and_delete_users) statement for statement: clear audit_logs.actor_id and admin_notifications (user_id + read_by), then DELETE FROM users, letting FK cascades handle the rest. It touches no encryption keys, so it cannot orphan retained encrypted data. Safety: dry-run by default; --pattern is required (no default, so a bare run can never match everything); role='admin' rows are always excluded; --commit additionally requires --i-know-this-is-not-prod plus a typed confirmation phrase. Operator previews the matched count/list before committing to confirm no intentional QA-seed accounts are caught. #BUNYIP-273