<field reporter:label="Is Mint Condition" name="mint_condition" reporter:datatype="bool" />
<field reporter:label="Shelf Expire Time" name="shelf_expire_time" reporter:datatype="timestamp"/>
<field reporter:label="Notes" name="notes" reporter:datatype="link" oils_persist:virtual="true"/>
+ <field reporter:label="Current Shelf Lib" name="current_shelf_lib" reporter:datatype="org_unit"/>
</fields>
<links>
<link field="fulfillment_lib" reltype="has_a" key="id" map="" class="aou"/>
<link field="bib_rec" reltype="might_have" key="id" map="" class="rhrr"/>
<link field="cancel_cause" reltype="might_have" key="id" map="" class="ahrcc"/>
<link field="notes" reltype="has_many" key="hold" map="" class="ahrn"/>
+ <link field="current_shelf_lib" reltype="has_a" key="id" map="" class="aou"/>
</links>
</class>
<class id="alhr" controller="open-ils.cstore" oils_obj:fieldmapper="action::last_hold_request" reporter:label="Last Captured Hold Request" oils_persist:readonly="true">
<field reporter:label="Is Mint Condition" name="mint_condition" reporter:datatype="bool" />
<field reporter:label="Shelf Expire Time" name="shelf_expire_time" reporter:datatype="timestamp"/>
<field reporter:label="Notes" name="notes" reporter:datatype="link" oils_persist:virtual="true"/>
+ <field reporter:label="Current Shelf Lib" name="current_shelf_lib" reporter:datatype="org_unit"/>
</fields>
<links>
<link field="fulfillment_lib" reltype="has_a" key="id" map="" class="aou"/>
<link field="bib_rec" reltype="might_have" key="id" map="" class="rhrr"/>
<link field="cancel_cause" reltype="might_have" key="id" map="" class="ahrcc"/>
<link field="notes" reltype="has_many" key="hold" map="" class="ahrn"/>
+ <link field="current_shelf_lib" reltype="has_a" key="id" map="" class="aou"/>
</links>
</class>
shelf_time TIMESTAMP WITH TIME ZONE,
cut_in_line BOOL,
mint_condition BOOL NOT NULL DEFAULT TRUE,
- shelf_expire_time TIMESTAMPTZ
+ shelf_expire_time TIMESTAMPTZ,
+ current_shelf_lib INT REFERENCES actor.org_unit DEFERRABLE INITIALLY DEFERRED
);
CREATE INDEX hold_request_target_idx ON action.hold_request (target);
--- /dev/null
+-- Evergreen DB patch XXXX.schema.hold-current-shelf-lib.sql
+--
+-- FIXME: insert description of change, if needed
+--
+BEGIN;
+
+
+-- check whether patch can be applied
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+-- add the new column
+ALTER TABLE action.hold_request ADD COLUMN current_shelf_lib
+ INT REFERENCES actor.org_unit DEFERRABLE INITIALLY DEFERRED;
+
+-- set the value for current_shelf_lib on existing shelved holds
+UPDATE action.hold_request ahr
+ SET current_shelf_lib = pickup_lib
+ FROM asset.copy acp
+ WHERE
+ ahr.shelf_time IS NOT NULL
+ AND ahr.capture_time IS NOT NULL
+ AND ahr.current_copy IS NOT NULL
+ AND ahr.fulfillment_time IS NULL
+ AND ahr.cancel_time IS NULL
+ AND acp.id = ahr.current_copy
+ AND acp.status = 8; -- on holds shelf
+
+COMMIT;