]> git.evergreen-ils.org Git - Evergreen.git/blob - Evergreen/src/extras/import/legacy_transit.sql
updating the profile map
[Evergreen.git] / Evergreen / src / extras / import / legacy_transit.sql
1 BEGIN;
2
3 -- hold transit import
4 INSERT INTO action.hold_transit_copy (dest, source, source_send_time, target_copy, copy_status, hold)
5         SELECT  dou.id AS dest,
6                 sou.id AS source,
7                 l.transit_date AS source_send_time,
8                 cp.id AS target_copy,
9                 8 AS copy_status,
10                 h.id AS hold
11         FROM    legacy_transit l
12                 JOIN action.hold_request h ON (l.hold_key = h.id)
13                 JOIN legacy_item li USING (cat_key, call_key, item_key)
14                 JOIN asset.copy cp ON (li.item_id = cp.barcode)
15                 JOIN actor.org_unit dou ON (l.destination_lib = dou.shortname)
16                 JOIN actor.org_unit sou ON (l.starting_lib = sou.shortname)
17         WHERE   l.hold_key > 0;
18
19 -- normal transits
20 INSERT INTO action.transit_copy (dest, source, source_send_time, target_copy, copy_status)
21         SELECT  dou.id AS dest,
22                 sou.id AS source,
23                 l.transit_date AS source_send_time,
24                 cp.id AS target_copy,
25                 7 AS copy_status
26         FROM    legacy_transit l
27                 JOIN legacy_item li USING (cat_key, call_key, item_key)
28                 JOIN asset.copy cp ON (li.item_id = cp.barcode)
29                 JOIN actor.org_unit dou ON (l.destination_lib = dou.shortname)
30                 JOIN actor.org_unit sou ON (l.starting_lib = sou.shortname)
31         WHERE   l.hold_key = 0;
32
33 COMMIT;