Ines Almeida has proposed merging 
~ines-almeida/launchpad:add-hw-submission-bug-to-account-deletion into 
launchpad:master.

Commit message:
Delete user's HW Submission Bugs before deleting its HW Submissions
    
This prevents an error where an account can't be deleted due to the 
HWSubmissions being referenced in the HWSubmissionBug table


Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~ines-almeida/launchpad/+git/launchpad/+merge/449003

While handling a GDPR request, I encountered an account that couldn't be 
deleted due to a refence error in HWSubmissionBug. Tested this DELETE command 
in dogfood and managed to clear the account afterwards.

I'd like to get this reviewed and then ask IS to run this delete command in 
production to be able to delete this user's account in production.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~ines-almeida/launchpad:add-hw-submission-bug-to-account-deletion into 
launchpad:master.
diff --git a/lib/lp/registry/scripts/closeaccount.py b/lib/lp/registry/scripts/closeaccount.py
index bd8fa4d..d744b92 100644
--- a/lib/lp/registry/scripts/closeaccount.py
+++ b/lib/lp/registry/scripts/closeaccount.py
@@ -417,6 +417,16 @@ def close_account(username, log):
         """,
         (person.id,),
     )
+    table_notification("HWSubmissionBug")
+    store.execute(
+        """
+        DELETE FROM HWSubmissionBug
+        USING HWSubmission
+        WHERE HWSubmission.id = HWSubmissionBug.submission
+            AND owner = ?
+        """,
+        (person.id,),
+    )
     table_notification("HWSubmission")
     store.execute(
         """
_______________________________________________
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp

Reply via email to