From: scottmk Date: Tue, 30 Jun 2009 13:06:20 +0000 (+0000) Subject: In actor.usr_merge(): when transferring rows from vandelay.queue, X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=0407e5713bb77b214a768a5399f1f1e105b77229;p=evergreen%2Fmasslnc.git In actor.usr_merge(): when transferring rows from vandelay.queue, change the name in order to avoid collisions with existing rows belonging to the destination user. git-svn-id: svn://svn.open-ils.org/ILS/trunk@13489 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/sql/Pg/999.functions.global.sql b/Open-ILS/src/sql/Pg/999.functions.global.sql index f0b8a59282..e0a238d7a1 100644 --- a/Open-ILS/src/sql/Pg/999.functions.global.sql +++ b/Open-ILS/src/sql/Pg/999.functions.global.sql @@ -49,6 +49,7 @@ DECLARE suffix TEXT; bucket_row RECORD; picklist_row RECORD; + queue_row RECORD; BEGIN -- do some initial cleanup @@ -175,7 +176,25 @@ BEGIN UPDATE container.user_bucket_item SET target_user = dest_usr WHERE target_user = src_usr; -- vandelay.* - PERFORM actor.usr_merge_rows('vandelay.queue', 'owner', src_usr, dest_usr); + -- transfer queues the same way we transfer buckets (see above) + FOR queue_row in + SELECT id, name + FROM vandelay.queue + WHERE owner = src_usr + LOOP + suffix := ' (' || src_usr || ')'; + LOOP + BEGIN + UPDATE vandelay.queue + SET owner = dest_usr, name = name || suffix + WHERE id = queue_row.id; + EXCEPTION WHEN unique_violation THEN + suffix := suffix || ' '; + CONTINUE; + END; + EXIT; + END LOOP; + END LOOP; -- money.* PERFORM actor.usr_merge_rows('money.collections_tracker', 'usr', src_usr, dest_usr);