fix(e2e): harden hard_delete against non-cascade user FKs (BUNYIP-248) #270
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/bunyip-248-fk-hardening"
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
Hardens the e2e disposable-account hard delete (BUNYIP-246) against the non-cascade
users(id)foreign keys a future disposable spec could populate. Implements BUNYIP-248.Why
UserRepository::hard_delete*cleared onlyaudit_logsbeforeDELETE FROM users. Other tables referenceusers(id)withoutON DELETE CASCADE:oauth_authorization_codes.user_id(an OIDC authorize),admin_notifications.user_id/read_by(a feedback submission), and the admin*_bycolumns. The current three specs populate onlyaudit_logs, but a future disposable spec exercising those flows would FK-block the delete - and because the reaper deletes in bulk, one blocking row would roll back and stall the whole sweep. Non-production / e2e only; production never hard-deletes (it soft-deletes), so there is no production exposure.Change (hybrid, per the issue decision)
20260629000010_oauth_auth_code_user_cascade.sql: recreateoauth_authorization_codes.user_idasON DELETE CASCADE- a pending code is the user's own ephemeral artifact, so it disappears with the user. Behavior-preserving for production (the CASCADE only fires on a hard delete, which production never does).hard_delete,hard_delete_by_email, andhard_delete_stale_disposablethrough oneclear_deps_and_delete_usershelper that clearsadmin_notifications(user_idrows deleted,read_bynulled) alongsideaudit_logs, then deletes the users by id. The reaper resolves eligible ids once (transaction-timestamp cutoff) rather than re-evaluatingNOW()across two statements.*_bynon-cascade refs are recorded as out of scope (only admin actions populate them; a subscriber disposable cannot), to be handled if an admin-disposable spec ever lands.Verification
just check-containergreen: fmt + clippy-D warnings+cargo test --workspace --lib(api 25, domain 222, oci 9, oidc 14). The FK / cleanup behavior runs against a live DB on api startup + e2e, not in--libtests; no.sqlxregen needed (the methods are runtime queries; the migration is plain DDL). No production behavior change.#BUNYIP-248
🤖 Generated with Claude Code