From: Jeremy Kerr Date: Wed, 7 May 2014 05:06:35 +0000 (+0800) Subject: migration: Add cleanup-people migration script X-Git-Url: https://git.ozlabs.org/?p=patchwork;a=commitdiff_plain;h=81a65cc81d151cbb412d2a833abab24dfc133a49 migration: Add cleanup-people migration script Now that we only create Person object once the User has been confirmed, we can clean up unused Person objects from the database. Signed-off-by: Jeremy Kerr --- diff --git a/lib/sql/migration/014-cleanup-people.sql b/lib/sql/migration/014-cleanup-people.sql new file mode 100644 index 0000000..7c10278 --- /dev/null +++ b/lib/sql/migration/014-cleanup-people.sql @@ -0,0 +1,7 @@ +BEGIN; +DELETE FROM patchwork_person WHERE id NOT IN ( + SELECT submitter_id FROM patchwork_patch + UNION + SELECT submitter_id FROM patchwork_comment) + AND user_id IS NULL; +COMMIT;