]> git.ozlabs.org Git - patchwork/blobdiff - lib/sql/migration/009-drop-registrationprofile.sql
registration: use EmailConfimation rather than separate registration app
[patchwork] / lib / sql / migration / 009-drop-registrationprofile.sql
diff --git a/lib/sql/migration/009-drop-registrationprofile.sql b/lib/sql/migration/009-drop-registrationprofile.sql
new file mode 100644 (file)
index 0000000..f1c2b43
--- /dev/null
@@ -0,0 +1,27 @@
+BEGIN;
+
+DELETE FROM registration_registrationprofile;
+
+-- unlink users who have contributed
+
+UPDATE patchwork_person SET user_id = NULL
+    WHERE user_id IN (SELECT id FROM auth_user WHERE is_active = False)
+           AND id IN (SELECT DISTINCT submitter_id FROM patchwork_comment);
+
+-- remove persons who only have a user linkage
+
+DELETE FROM patchwork_person WHERE user_id IN
+    (SELECT id FROM auth_user WHERE is_active = False);
+
+-- delete profiles
+
+DELETE FROM patchwork_userprofile WHERE user_id IN
+    (SELECT id FROM auth_user WHERE is_active = False);
+
+-- delete inactive users
+
+DELETE FROM auth_user WHERE is_active = False;
+
+DROP TABLE registration_registrationprofile;
+
+COMMIT;