Commits

Anonymous committed c45df79

Bugfix in "delete_private_data"(); Extended "delete_member_data"(...)

- Do not delete delegations in "delete_private_data"()
- Delete area memberships in "delete_member_data"(...)
- Update script for new version 1.0.2

  • Participants
  • Parent commits d54d0d8
  • Tags v1.0.2

Comments (0)

Files changed (2)

 BEGIN;
 
 CREATE VIEW "liquid_feedback_version" AS
-  SELECT * FROM (VALUES ('1.0.1', 1, 0, 1))
+  SELECT * FROM (VALUES ('1.0.2', 1, 0, 2))
   AS "subquery"("string", "major", "minor", "revision");
 
 
       DELETE FROM "member_image"       WHERE "member_id" = "member_id_p";
       DELETE FROM "contact"            WHERE "member_id" = "member_id_p";
       DELETE FROM "delegation"         WHERE "truster_id" = "member_id_p";
+      DELETE FROM "membership"         WHERE "member_id" = "member_id_p";
       DELETE FROM "area_setting"       WHERE "member_id" = "member_id_p";
       DELETE FROM "issue_setting"      WHERE "member_id" = "member_id_p";
       DELETE FROM "initiative_setting" WHERE "member_id" = "member_id_p";
   RETURNS VOID
   LANGUAGE 'plpgsql' VOLATILE AS $$
     BEGIN
-      PERFORM "delete_member_data"("id") FROM "member";
+      UPDATE "member" SET
+        "login"                        = NULL,
+        "password"                     = NULL,
+        "notify_email"                 = NULL,
+        "notify_email_unconfirmed"     = NULL,
+        "notify_email_secret"          = NULL,
+        "notify_email_secret_expiry"   = NULL,
+        "password_reset_secret"        = NULL,
+        "password_reset_secret_expiry" = NULL,
+        "organizational_unit"          = NULL,
+        "internal_posts"               = NULL,
+        "realname"                     = NULL,
+        "birthday"                     = NULL,
+        "address"                      = NULL,
+        "email"                        = NULL,
+        "xmpp_address"                 = NULL,
+        "website"                      = NULL,
+        "phone"                        = NULL,
+        "mobile_phone"                 = NULL,
+        "profession"                   = NULL,
+        "external_memberships"         = NULL,
+        "external_posts"               = NULL,
+        "statement"                    = NULL;
+      -- "text_search_data" is updated by triggers
+      UPDATE "member_history" SET "login" = NULL;
+      DELETE FROM "setting";
+      DELETE FROM "setting_map";
+      DELETE FROM "member_relation_setting";
+      DELETE FROM "member_image";
+      DELETE FROM "contact";
+      DELETE FROM "area_setting";
+      DELETE FROM "issue_setting";
+      DELETE FROM "initiative_setting";
+      DELETE FROM "suggestion_setting";
       DELETE FROM "invite_code";
       DELETE FROM "session";
       DELETE FROM "direct_voter" USING "issue"

File update/core-update.v1.0.1-v1.0.2.sql

+BEGIN;
+
+CREATE OR REPLACE VIEW "liquid_feedback_version" AS
+  SELECT * FROM (VALUES ('1.0.2', 1, 0, 2))
+  AS "subquery"("string", "major", "minor", "revision");
+ 
+CREATE OR REPLACE FUNCTION "delete_member_data"("member_id_p" "member"."id"%TYPE)
+  RETURNS VOID
+  LANGUAGE 'plpgsql' VOLATILE AS $$
+    BEGIN
+      UPDATE "member" SET
+        "login"                        = NULL,
+        "password"                     = NULL,
+        "notify_email"                 = NULL,
+        "notify_email_unconfirmed"     = NULL,
+        "notify_email_secret"          = NULL,
+        "notify_email_secret_expiry"   = NULL,
+        "password_reset_secret"        = NULL,
+        "password_reset_secret_expiry" = NULL,
+        "organizational_unit"          = NULL,
+        "internal_posts"               = NULL,
+        "realname"                     = NULL,
+        "birthday"                     = NULL,
+        "address"                      = NULL,
+        "email"                        = NULL,
+        "xmpp_address"                 = NULL,
+        "website"                      = NULL,
+        "phone"                        = NULL,
+        "mobile_phone"                 = NULL,
+        "profession"                   = NULL,
+        "external_memberships"         = NULL,
+        "external_posts"               = NULL,
+        "statement"                    = NULL
+        WHERE "id" = "member_id_p";
+      -- "text_search_data" is updated by triggers
+      UPDATE "member_history" SET "login" = NULL
+        WHERE "member_id" = "member_id_p";
+      DELETE FROM "setting"            WHERE "member_id" = "member_id_p";
+      DELETE FROM "setting_map"        WHERE "member_id" = "member_id_p";
+      DELETE FROM "member_relation_setting" WHERE "member_id" = "member_id_p";
+      DELETE FROM "member_image"       WHERE "member_id" = "member_id_p";
+      DELETE FROM "contact"            WHERE "member_id" = "member_id_p";
+      DELETE FROM "delegation"         WHERE "truster_id" = "member_id_p";
+      DELETE FROM "membership"         WHERE "member_id" = "member_id_p";
+      DELETE FROM "area_setting"       WHERE "member_id" = "member_id_p";
+      DELETE FROM "issue_setting"      WHERE "member_id" = "member_id_p";
+      DELETE FROM "initiative_setting" WHERE "member_id" = "member_id_p";
+      DELETE FROM "suggestion_setting" WHERE "member_id" = "member_id_p";
+      RETURN;
+    END;
+  $$;
+
+CREATE OR REPLACE FUNCTION "delete_private_data"()
+  RETURNS VOID
+  LANGUAGE 'plpgsql' VOLATILE AS $$
+    BEGIN
+      UPDATE "member" SET
+        "login"                        = NULL,
+        "password"                     = NULL,
+        "notify_email"                 = NULL,
+        "notify_email_unconfirmed"     = NULL,
+        "notify_email_secret"          = NULL,
+        "notify_email_secret_expiry"   = NULL,
+        "password_reset_secret"        = NULL,
+        "password_reset_secret_expiry" = NULL,
+        "organizational_unit"          = NULL,
+        "internal_posts"               = NULL,
+        "realname"                     = NULL,
+        "birthday"                     = NULL,
+        "address"                      = NULL,
+        "email"                        = NULL,
+        "xmpp_address"                 = NULL,
+        "website"                      = NULL,
+        "phone"                        = NULL,
+        "mobile_phone"                 = NULL,
+        "profession"                   = NULL,
+        "external_memberships"         = NULL,
+        "external_posts"               = NULL,
+        "statement"                    = NULL;
+      -- "text_search_data" is updated by triggers
+      UPDATE "member_history" SET "login" = NULL;
+      DELETE FROM "setting";
+      DELETE FROM "setting_map";
+      DELETE FROM "member_relation_setting";
+      DELETE FROM "member_image";
+      DELETE FROM "contact";
+      DELETE FROM "area_setting";
+      DELETE FROM "issue_setting";
+      DELETE FROM "initiative_setting";
+      DELETE FROM "suggestion_setting";
+      DELETE FROM "invite_code";
+      DELETE FROM "session";
+      DELETE FROM "direct_voter" USING "issue"
+        WHERE "direct_voter"."issue_id" = "issue"."id"
+        AND "issue"."closed" ISNULL;
+      RETURN;
+    END;
+  $$;
+
+COMMIT;