From ee49a66f63b888876a86a6bf01bceb6cb4fb43e3 Mon Sep 17 00:00:00 2001 From: miker Date: Fri, 4 Aug 2006 19:51:45 +0000 Subject: [PATCH] import fixes git-svn-id: svn://svn.open-ils.org/ILS/trunk@5308 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Evergreen/src/extras/import/legacy_hold.sql | 19 +++++++---- .../src/extras/import/legacy_transit.sql | 33 +++++++++++++++++++ 2 files changed, 45 insertions(+), 7 deletions(-) create mode 100644 Evergreen/src/extras/import/legacy_transit.sql diff --git a/Evergreen/src/extras/import/legacy_hold.sql b/Evergreen/src/extras/import/legacy_hold.sql index dc7fce9a50..2c6445bcc6 100644 --- a/Evergreen/src/extras/import/legacy_hold.sql +++ b/Evergreen/src/extras/import/legacy_hold.sql @@ -3,9 +3,10 @@ BEGIN; -- These are copy level holds -- CREATE TABLE legacy_copy_hold_insert AS INSERT INTO action.hold_request - (target, current_copy, hold_type, pickup_lib, selection_ou, selection_depth, request_time, capture_time, request_lib, requestor, usr) - SELECT cp.id AS target, + (id, target, current_copy, hold_type, pickup_lib, selection_ou, selection_depth, request_time, capture_time, request_lib, requestor, usr) + SELECT lh.hold_key AS id, cp.id AS target, + cp.id AS current_copy, 'C'::TEXT AS hold_type, pou.id AS pickup_lib, pou.id AS selection_ou, @@ -34,8 +35,9 @@ INSERT INTO action.hold_request -- And these are CN level holds -- CREATE TABLE legacy_cn_hold_insert AS INSERT INTO action.hold_request - (target, current_copy, hold_type, pickup_lib, selection_ou, selection_depth, request_time, capture_time, request_lib, requestor, usr) - SELECT cp.call_number AS target, + (id, target, current_copy, hold_type, pickup_lib, selection_ou, selection_depth, request_time, capture_time, request_lib, requestor, usr) + SELECT lh.hold_key AS id, + cp.call_number AS target, cp.id AS current_copy, 'V'::TEXT AS hold_type, pou.id AS pickup_lib, @@ -65,8 +67,9 @@ INSERT INTO action.hold_request -- And these are CN level holds -- CREATE TABLE legacy_title_hold_insert AS INSERT INTO action.hold_request - (target, current_copy, hold_type, pickup_lib, selection_ou, selection_depth, request_time, capture_time, request_lib, requestor, usr) - SELECT lh.cat_key AS target, + (id, target, current_copy, hold_type, pickup_lib, selection_ou, selection_depth, request_time, capture_time, request_lib, requestor, usr) + SELECT lh.hold_key AS id, + lh.cat_key AS target, cp.id AS current_copy, 'T'::TEXT AS hold_type, pou.id AS pickup_lib, @@ -93,4 +96,6 @@ INSERT INTO action.hold_request JOIN actor.org_unit pou ON (pou.shortname = lh.pickup_lib) WHERE lh.hold_level = 'T'; ---COMMIT; +SELECT SETVAL('action.hold_request_id_seq',(SELECT MAX(id) FROM action.hold_request),TRUE); + +COMMIT; diff --git a/Evergreen/src/extras/import/legacy_transit.sql b/Evergreen/src/extras/import/legacy_transit.sql new file mode 100644 index 0000000000..3ff3c5dcb3 --- /dev/null +++ b/Evergreen/src/extras/import/legacy_transit.sql @@ -0,0 +1,33 @@ +BEGIN; + +-- hold transit import +INSERT INTO action.hold_transit_copy (dest, source, source_send_time, target_copy, copy_status, hold) + SELECT dou.id AS dest, + sou.id AS source, + l.transit_date AS source_send_time, + cp.id AS target_copy, + 8 AS copy_status, + h.id AS hold + FROM legacy_transit l + JOIN action.hold_request h ON (l.hold_key = h.id) + JOIN legacy_item li USING (cat_key, call_key, item_key) + JOIN asset.copy cp ON (li.item_id = cp.barcode) + JOIN actor.org_unit dou ON (l.destination_lib = dou.shortname) + JOIN actor.org_unit sou ON (l.starting_lib = sou.shortname) + WHERE l.hold_key > 0; + +-- normal transits +INSERT INTO action.transit_copy (dest, source, source_send_time, target_copy, copy_status) + SELECT dou.id AS dest, + sou.id AS source, + l.transit_date AS source_send_time, + cp.id AS target_copy, + 7 AS copy_status + FROM legacy_transit l + JOIN legacy_item li USING (cat_key, call_key, item_key) + JOIN asset.copy cp ON (li.item_id = cp.barcode) + JOIN actor.org_unit dou ON (l.destination_lib = dou.shortname) + JOIN actor.org_unit sou ON (l.starting_lib = sou.shortname) + WHERE l.hold_key = 0; + +COMMIT; -- 2.43.2