From: Galen Charlton Date: Mon, 27 Jul 2020 14:51:37 +0000 (-0400) Subject: LP#1802166: (follow-up) document a way to clear names from already-purged patron... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=f3bdc3d12df98bfd59052b8478d6101add44e2aa;p=contrib%2FConifer.git LP#1802166: (follow-up) document a way to clear names from already-purged patron records For reference, the following SQL will clear the preferred name and name keyword fields from already-purged records: UPDATE actor.usr SET pref_prefix = NULL, pref_first_given_name = NULL, pref_second_given_name = NULL, pref_family_name = NULL, pref_suffix = NULL, name_keywords = NULL WHERE usrname ~ ('^' || id || '-PURGED') AND NOT active AND deleted AND ( pref_prefix IS NOT NULL OR pref_first_given_name IS NOT NULL OR pref_second_given_name IS NOT NULL OR pref_family_name IS NOT NULL OR pref_suffix IS NOT NULL OR name_keywords IS NOT NULL ); Signed-off-by: Galen Charlton --- diff --git a/docs/RELEASE_NOTES_NEXT/Circulation/purge_usr_pref_names.adoc b/docs/RELEASE_NOTES_NEXT/Circulation/purge_usr_pref_names.adoc index bb3eb22e26..6f16aaaeb4 100644 --- a/docs/RELEASE_NOTES_NEXT/Circulation/purge_usr_pref_names.adoc +++ b/docs/RELEASE_NOTES_NEXT/Circulation/purge_usr_pref_names.adoc @@ -3,3 +3,28 @@ Purge User Preferred Names The new, user preferred name fields are now set to NULL in the database when a user account is purged via the staff client or using the actor.usr_delete function in the database. + +To clear the preferred name fields from records that have already been +purged, run the following SQL update: + +[source,sql] +---- +UPDATE actor.usr +SET pref_prefix = NULL, + pref_first_given_name = NULL, + pref_second_given_name = NULL, + pref_family_name = NULL, + pref_suffix = NULL, + name_keywords = NULL +WHERE usrname ~ ('^' || id || '-PURGED') +AND NOT active +AND deleted +AND ( + pref_prefix IS NOT NULL OR + pref_first_given_name IS NOT NULL OR + pref_second_given_name IS NOT NULL OR + pref_family_name IS NOT NULL OR + pref_suffix IS NOT NULL OR + name_keywords IS NOT NULL +); +----