Regarding comments from this ticket [MODSOURMAN-627] Kiwi bugfest - Data integrity issues with instances/holdings records - FOLIO Issue Tracker:
a. If the holdings source is anything other than FOLIO or MARC (e.g. -), then change to FOLIO.
b. If the holdings source = MARC, check to see if there is a linked SRS MARC Holdings record. If yes, then keep the Holdings source as MARC, and ensure that View source and Edit via QM works for the Inventory Holdings record. If no, then set the Holdings source as FOLIO, and ensure that View source/Edit in QM do not display in the Holdings Action menu.
There were created scripts for retrieving these holdings. This is NOT update operations. These scripts just show valid/invalid Holdings from DB by conditions from comment.
- Retrieve holdings where the source is anything other than FOLIO or MARC (e.g. -):
SELECT * FROM ${tenant}_mod_inventory_storage.holdings_record WHERE ${tenant}_mod_inventory_storage.holdings_record.jsonb ->> 'sourceId' = ( SELECT id::text FROM ${tenant}_mod_inventory_storage.holdings_records_source WHERE ${tenant}_mod_inventory_storage.holdings_records_source.jsonb ->> 'name' != 'FOLIO' AND ${tenant}_mod_inventory_storage.holdings_records_source.jsonb ->> 'name' != 'MARC');
2. Retrieve holdings where source= MARC and there is existing linked SRS MARC HOLDINGS record (by external_hrid) from records_lb from source-record-storage schema.
SELECT * FROM ${tenant}_mod_inventory_storage.holdings_record RIGHT JOIN ${tenant}_mod_source_record_storage.records_lb ON ${tenant}_mod_inventory_storage.holdings_record.jsonb->>'hrid' = ${tenant}_mod_source_record_storage.records_lb.external_hrid WHERE ${tenant}_mod_inventory_storage.holdings_record.jsonb ->> 'sourceId' = ( SELECT id::text FROM ${tenant}_mod_inventory_storage.holdings_records_source WHERE ${tenant}_mod_inventory_storage.holdings_records_source.jsonb ->> 'name' = 'MARC');
3. Retrieve holdings where source= MARC and there is NO existing SRS MARC HOLDINGS record (by external_hrid) from records_lb from source-record-storage schema.
SELECT * FROM ${tenant}_mod_inventory_storage.holdings_record WHERE ${tenant}_mod_inventory_storage.holdings_record.jsonb ->> 'sourceId' = ( SELECT id::text FROM ${tenant}_mod_inventory_storage.holdings_records_source WHERE ${tenant}_mod_inventory_storage.holdings_records_source.jsonb ->> 'name' = 'MARC') AND NOT EXISTS (SELECT * FROM ${tenant}_mod_source_record_storage.records_lb WHERE ${tenant}_mod_source_record_storage.records_lb.external_hrid = ${tenant}_mod_inventory_storage.holdings_record.jsonb->>'hrid');