]> git.ozlabs.org Git - patchwork/commitdiff
migration: Add cleanup-people migration script
authorJeremy Kerr <jk@ozlabs.org>
Wed, 7 May 2014 05:06:35 +0000 (13:06 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Thu, 8 May 2014 03:05:33 +0000 (11:05 +0800)
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 <jk@ozlabs.org>
lib/sql/migration/014-cleanup-people.sql [new file with mode: 0644]

diff --git a/lib/sql/migration/014-cleanup-people.sql b/lib/sql/migration/014-cleanup-people.sql
new file mode 100644 (file)
index 0000000..7c10278
--- /dev/null
@@ -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;