From: Bill Erickson Date: Tue, 18 Feb 2014 19:16:40 +0000 (-0500) Subject: LP#1281744 Aged hold purging column repair X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=11d70bcabf0aeef6392b540b2398d906011d0bd1;p=evergreen%2Fpines.git LP#1281744 Aged hold purging column repair Add missing non-NULLable "behind_desk" column to action.all_hold_request, which is used during holds deletion and archiving. Signed-off-by: Bill Erickson Signed-off-by: Dan Wells --- diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index e86ee9cad3..adfcd2eb15 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -5628,6 +5628,7 @@ SELECT usr, + diff --git a/Open-ILS/src/sql/Pg/090.schema.action.sql b/Open-ILS/src/sql/Pg/090.schema.action.sql index 6ab9ab42e1..35ab53bc2e 100644 --- a/Open-ILS/src/sql/Pg/090.schema.action.sql +++ b/Open-ILS/src/sql/Pg/090.schema.action.sql @@ -587,7 +587,8 @@ CREATE OR REPLACE VIEW action.all_hold_request AS ahr.cut_in_line, ahr.mint_condition, ahr.shelf_expire_time, - ahr.current_shelf_lib + ahr.current_shelf_lib, + ahr.behind_desk FROM action.hold_request ahr JOIN actor.usr p ON (ahr.usr = p.id) LEFT JOIN actor.usr_address a ON (p.mailing_address = a.id) @@ -629,7 +630,8 @@ CREATE OR REPLACE VIEW action.all_hold_request AS cut_in_line, mint_condition, shelf_expire_time, - current_shelf_lib + current_shelf_lib, + behind_desk FROM action.aged_hold_request; CREATE OR REPLACE FUNCTION action.age_hold_on_delete () RETURNS TRIGGER AS $$ @@ -673,7 +675,8 @@ BEGIN cut_in_line, mint_condition, shelf_expire_time, - current_shelf_lib) + current_shelf_lib, + behind_desk) SELECT usr_post_code, usr_home_ou, @@ -710,7 +713,8 @@ BEGIN cut_in_line, mint_condition, shelf_expire_time, - current_shelf_lib + current_shelf_lib, + behind_desk FROM action.all_hold_request WHERE id = OLD.id; RETURN OLD; diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.all_hold_behind_desk.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.all_hold_behind_desk.sql new file mode 100644 index 0000000000..c2c6e955d0 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.all_hold_behind_desk.sql @@ -0,0 +1,187 @@ +-- add missing behind_desk column + +BEGIN; + +CREATE OR REPLACE VIEW action.all_hold_request AS + SELECT DISTINCT + COALESCE(a.post_code, b.post_code) AS usr_post_code, + p.home_ou AS usr_home_ou, + p.profile AS usr_profile, + EXTRACT(YEAR FROM p.dob)::INT AS usr_birth_year, + CAST(ahr.requestor <> ahr.usr AS BOOLEAN) AS staff_placed, + ahr.id, + ahr.request_time, + ahr.capture_time, + ahr.fulfillment_time, + ahr.checkin_time, + ahr.return_time, + ahr.prev_check_time, + ahr.expire_time, + ahr.cancel_time, + ahr.cancel_cause, + ahr.cancel_note, + ahr.target, + ahr.current_copy, + ahr.fulfillment_staff, + ahr.fulfillment_lib, + ahr.request_lib, + ahr.selection_ou, + ahr.selection_depth, + ahr.pickup_lib, + ahr.hold_type, + ahr.holdable_formats, + CASE + WHEN ahr.phone_notify IS NULL THEN FALSE + WHEN ahr.phone_notify = '' THEN FALSE + ELSE TRUE + END AS phone_notify, + ahr.email_notify, + CASE + WHEN ahr.sms_notify IS NULL THEN FALSE + WHEN ahr.sms_notify = '' THEN FALSE + ELSE TRUE + END AS sms_notify, + ahr.frozen, + ahr.thaw_date, + ahr.shelf_time, + ahr.cut_in_line, + ahr.mint_condition, + ahr.shelf_expire_time, + ahr.current_shelf_lib, + ahr.behind_desk + FROM action.hold_request ahr + JOIN actor.usr p ON (ahr.usr = p.id) + LEFT JOIN actor.usr_address a ON (p.mailing_address = a.id) + LEFT JOIN actor.usr_address b ON (p.billing_address = b.id) + UNION ALL + SELECT + usr_post_code, + usr_home_ou, + usr_profile, + usr_birth_year, + staff_placed, + id, + request_time, + capture_time, + fulfillment_time, + checkin_time, + return_time, + prev_check_time, + expire_time, + cancel_time, + cancel_cause, + cancel_note, + target, + current_copy, + fulfillment_staff, + fulfillment_lib, + request_lib, + selection_ou, + selection_depth, + pickup_lib, + hold_type, + holdable_formats, + phone_notify, + email_notify, + sms_notify, + frozen, + thaw_date, + shelf_time, + cut_in_line, + mint_condition, + shelf_expire_time, + current_shelf_lib, + behind_desk + FROM action.aged_hold_request; + + + +CREATE OR REPLACE FUNCTION action.age_hold_on_delete () RETURNS TRIGGER AS $$ +DECLARE +BEGIN + -- Archive a copy of the old row to action.aged_hold_request + + INSERT INTO action.aged_hold_request + (usr_post_code, + usr_home_ou, + usr_profile, + usr_birth_year, + staff_placed, + id, + request_time, + capture_time, + fulfillment_time, + checkin_time, + return_time, + prev_check_time, + expire_time, + cancel_time, + cancel_cause, + cancel_note, + target, + current_copy, + fulfillment_staff, + fulfillment_lib, + request_lib, + selection_ou, + selection_depth, + pickup_lib, + hold_type, + holdable_formats, + phone_notify, + email_notify, + sms_notify, + frozen, + thaw_date, + shelf_time, + cut_in_line, + mint_condition, + shelf_expire_time, + current_shelf_lib, + behind_desk) + SELECT + usr_post_code, + usr_home_ou, + usr_profile, + usr_birth_year, + staff_placed, + id, + request_time, + capture_time, + fulfillment_time, + checkin_time, + return_time, + prev_check_time, + expire_time, + cancel_time, + cancel_cause, + cancel_note, + target, + current_copy, + fulfillment_staff, + fulfillment_lib, + request_lib, + selection_ou, + selection_depth, + pickup_lib, + hold_type, + holdable_formats, + phone_notify, + email_notify, + sms_notify, + frozen, + thaw_date, + shelf_time, + cut_in_line, + mint_condition, + shelf_expire_time, + current_shelf_lib, + behind_desk + FROM action.all_hold_request WHERE id = OLD.id; + + RETURN OLD; +END; +$$ LANGUAGE 'plpgsql'; + +COMMIT; +