From: Chris Sharp Date: Wed, 15 Oct 2014 21:19:11 +0000 (-0400) Subject: Adding our "unmerge" script to ease the correction of patron accounts X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=bcfd527f3373d2518566ebbb26e8e768f235dc75;p=contrib%2Fpines.git Adding our "unmerge" script to ease the correction of patron accounts merged in error. --- diff --git a/patron-merge-tools/unmerge.sh b/patron-merge-tools/unmerge.sh new file mode 100755 index 0000000..9132633 --- /dev/null +++ b/patron-merge-tools/unmerge.sh @@ -0,0 +1,196 @@ +#!/bin/bash + +# (C) 2014 Georgia Public Library Service +# Chris Sharp +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# We found after running our automated patron deduplication program that +# several users were merged together in error. This script is an attempt +# to ease the "unmerge" process. Note that merges are pretty much +# permanent, so this script doesn't fully undo the merge. +# +# Usage: enter the lead patron barcode and merged patron barcode. Get +# circ/hold information from the staff client and manually paste in the +# ids. There is not a safe automated way to do that :-/. +# +# TODO: Implement this script in Perl using DBI. In the meantime, +# make this script more accommodating if there's more than one address +# that needs to be transferred, or more than one user who got merged +# with the same lead user. + +PSQL="/usr/bin/psql" +PSQL_USER="evergreen" + +read -p "Please enter the lead patron's barcode: " LEAD_PATRON_BARCODE +read -p "Please enter the merged patron's barcode: " MERGE_PATRON_BARCODE + +read -d '' LEAD_PATRON_SQL < usr +AND lead_usr = $LEAD_PATRON_ID +EOF + +MERGE_PATRON_ID=`$PSQL -U $PSQL_USER -A -t -c "$MERGE_PATRON_SQL"` + +read -d '' LEAD_PATRON_HOME_OU_SQL <