liquid_feedback_core
changeset 522:2f1c06608def
Fixed functions "delete_member" and "delete_private_data" to properly handle NULL constraints of "member" table
author | jbe |
---|---|
date | Wed May 04 21:49:25 2016 +0200 (2016-05-04) |
parents | 65bd17395c28 |
children | 30b67ca0c242 |
files | core.sql update/core-update.v3.2.1-v3.2.2.sql |
line diff
1.1 --- a/core.sql Wed May 04 21:47:29 2016 +0200 1.2 +++ b/core.sql Wed May 04 21:49:25 2016 +0200 1.3 @@ -5097,9 +5097,9 @@ 1.4 "notify_email_secret" = NULL, 1.5 "notify_email_secret_expiry" = NULL, 1.6 "notify_email_lock_expiry" = NULL, 1.7 - "disable_notifications" = NULL, 1.8 - "notification_counter" = NULL, 1.9 - "notification_sample_size" = NULL, 1.10 + "disable_notifications" = TRUE, 1.11 + "notification_counter" = DEFAULT, 1.12 + "notification_sample_size" = 0, 1.13 "notification_dow" = NULL, 1.14 "notification_hour" = NULL, 1.15 "login_recovery_expiry" = NULL, 1.16 @@ -5170,9 +5170,9 @@ 1.17 "notify_email_secret" = NULL, 1.18 "notify_email_secret_expiry" = NULL, 1.19 "notify_email_lock_expiry" = NULL, 1.20 - "disable_notifications" = NULL, 1.21 - "notification_counter" = NULL, 1.22 - "notification_sample_size" = NULL, 1.23 + "disable_notifications" = TRUE, 1.24 + "notification_counter" = DEFAULT, 1.25 + "notification_sample_size" = 0, 1.26 "notification_dow" = NULL, 1.27 "notification_hour" = NULL, 1.28 "login_recovery_expiry" = NULL,
2.1 --- a/update/core-update.v3.2.1-v3.2.2.sql Wed May 04 21:47:29 2016 +0200 2.2 +++ b/update/core-update.v3.2.1-v3.2.2.sql Wed May 04 21:49:25 2016 +0200 2.3 @@ -137,4 +137,137 @@ 2.4 ) AS "subquery2" 2.5 WHERE "pending" > '0'::INTERVAL; 2.6 2.7 +CREATE OR REPLACE FUNCTION "delete_member"("member_id_p" "member"."id"%TYPE) 2.8 + RETURNS VOID 2.9 + LANGUAGE 'plpgsql' VOLATILE AS $$ 2.10 + BEGIN 2.11 + UPDATE "member" SET 2.12 + "last_login" = NULL, 2.13 + "last_delegation_check" = NULL, 2.14 + "login" = NULL, 2.15 + "password" = NULL, 2.16 + "authority" = NULL, 2.17 + "authority_uid" = NULL, 2.18 + "authority_login" = NULL, 2.19 + "locked" = TRUE, 2.20 + "active" = FALSE, 2.21 + "notify_email" = NULL, 2.22 + "notify_email_unconfirmed" = NULL, 2.23 + "notify_email_secret" = NULL, 2.24 + "notify_email_secret_expiry" = NULL, 2.25 + "notify_email_lock_expiry" = NULL, 2.26 + "disable_notifications" = TRUE, 2.27 + "notification_counter" = DEFAULT, 2.28 + "notification_sample_size" = 0, 2.29 + "notification_dow" = NULL, 2.30 + "notification_hour" = NULL, 2.31 + "login_recovery_expiry" = NULL, 2.32 + "password_reset_secret" = NULL, 2.33 + "password_reset_secret_expiry" = NULL, 2.34 + "organizational_unit" = NULL, 2.35 + "internal_posts" = NULL, 2.36 + "realname" = NULL, 2.37 + "birthday" = NULL, 2.38 + "address" = NULL, 2.39 + "email" = NULL, 2.40 + "xmpp_address" = NULL, 2.41 + "website" = NULL, 2.42 + "phone" = NULL, 2.43 + "mobile_phone" = NULL, 2.44 + "profession" = NULL, 2.45 + "external_memberships" = NULL, 2.46 + "external_posts" = NULL, 2.47 + "statement" = NULL 2.48 + WHERE "id" = "member_id_p"; 2.49 + -- "text_search_data" is updated by triggers 2.50 + DELETE FROM "setting" WHERE "member_id" = "member_id_p"; 2.51 + DELETE FROM "setting_map" WHERE "member_id" = "member_id_p"; 2.52 + DELETE FROM "member_relation_setting" WHERE "member_id" = "member_id_p"; 2.53 + DELETE FROM "member_image" WHERE "member_id" = "member_id_p"; 2.54 + DELETE FROM "contact" WHERE "member_id" = "member_id_p"; 2.55 + DELETE FROM "ignored_member" WHERE "member_id" = "member_id_p"; 2.56 + DELETE FROM "session" WHERE "member_id" = "member_id_p"; 2.57 + DELETE FROM "area_setting" WHERE "member_id" = "member_id_p"; 2.58 + DELETE FROM "issue_setting" WHERE "member_id" = "member_id_p"; 2.59 + DELETE FROM "ignored_initiative" WHERE "member_id" = "member_id_p"; 2.60 + DELETE FROM "initiative_setting" WHERE "member_id" = "member_id_p"; 2.61 + DELETE FROM "suggestion_setting" WHERE "member_id" = "member_id_p"; 2.62 + DELETE FROM "membership" WHERE "member_id" = "member_id_p"; 2.63 + DELETE FROM "delegation" WHERE "truster_id" = "member_id_p"; 2.64 + DELETE FROM "non_voter" WHERE "member_id" = "member_id_p"; 2.65 + DELETE FROM "direct_voter" USING "issue" 2.66 + WHERE "direct_voter"."issue_id" = "issue"."id" 2.67 + AND "issue"."closed" ISNULL 2.68 + AND "member_id" = "member_id_p"; 2.69 + RETURN; 2.70 + END; 2.71 + $$; 2.72 + 2.73 +CREATE OR REPLACE FUNCTION "delete_private_data"() 2.74 + RETURNS VOID 2.75 + LANGUAGE 'plpgsql' VOLATILE AS $$ 2.76 + BEGIN 2.77 + DELETE FROM "temporary_transaction_data"; 2.78 + DELETE FROM "member" WHERE "activated" ISNULL; 2.79 + UPDATE "member" SET 2.80 + "invite_code" = NULL, 2.81 + "invite_code_expiry" = NULL, 2.82 + "admin_comment" = NULL, 2.83 + "last_login" = NULL, 2.84 + "last_delegation_check" = NULL, 2.85 + "login" = NULL, 2.86 + "password" = NULL, 2.87 + "authority" = NULL, 2.88 + "authority_uid" = NULL, 2.89 + "authority_login" = NULL, 2.90 + "lang" = NULL, 2.91 + "notify_email" = NULL, 2.92 + "notify_email_unconfirmed" = NULL, 2.93 + "notify_email_secret" = NULL, 2.94 + "notify_email_secret_expiry" = NULL, 2.95 + "notify_email_lock_expiry" = NULL, 2.96 + "disable_notifications" = TRUE, 2.97 + "notification_counter" = DEFAULT, 2.98 + "notification_sample_size" = 0, 2.99 + "notification_dow" = NULL, 2.100 + "notification_hour" = NULL, 2.101 + "login_recovery_expiry" = NULL, 2.102 + "password_reset_secret" = NULL, 2.103 + "password_reset_secret_expiry" = NULL, 2.104 + "organizational_unit" = NULL, 2.105 + "internal_posts" = NULL, 2.106 + "realname" = NULL, 2.107 + "birthday" = NULL, 2.108 + "address" = NULL, 2.109 + "email" = NULL, 2.110 + "xmpp_address" = NULL, 2.111 + "website" = NULL, 2.112 + "phone" = NULL, 2.113 + "mobile_phone" = NULL, 2.114 + "profession" = NULL, 2.115 + "external_memberships" = NULL, 2.116 + "external_posts" = NULL, 2.117 + "formatting_engine" = NULL, 2.118 + "statement" = NULL; 2.119 + -- "text_search_data" is updated by triggers 2.120 + DELETE FROM "setting"; 2.121 + DELETE FROM "setting_map"; 2.122 + DELETE FROM "member_relation_setting"; 2.123 + DELETE FROM "member_image"; 2.124 + DELETE FROM "contact"; 2.125 + DELETE FROM "ignored_member"; 2.126 + DELETE FROM "session"; 2.127 + DELETE FROM "area_setting"; 2.128 + DELETE FROM "issue_setting"; 2.129 + DELETE FROM "ignored_initiative"; 2.130 + DELETE FROM "initiative_setting"; 2.131 + DELETE FROM "suggestion_setting"; 2.132 + DELETE FROM "non_voter"; 2.133 + DELETE FROM "direct_voter" USING "issue" 2.134 + WHERE "direct_voter"."issue_id" = "issue"."id" 2.135 + AND "issue"."closed" ISNULL; 2.136 + RETURN; 2.137 + END; 2.138 + $$; 2.139 + 2.140 COMMIT;