import fixes
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 4 Aug 2006 19:51:45 +0000 (19:51 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 4 Aug 2006 19:51:45 +0000 (19:51 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@5308 dcc99617-32d9-48b4-a31d-7c20da2025e4

Evergreen/src/extras/import/legacy_hold.sql
Evergreen/src/extras/import/legacy_transit.sql [new file with mode: 0644]

index dc7fce9..2c6445b 100644 (file)
@@ -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 (file)
index 0000000..3ff3c5d
--- /dev/null
@@ -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;