Skip to content

Commit

Permalink
MODLISTS-123 Turn an update into an upsert
Browse files Browse the repository at this point in the history
  • Loading branch information
mweaver-ebsco committed Sep 27, 2024
1 parent ada04e1 commit d9bb192
Showing 1 changed file with 43 additions and 12 deletions.
55 changes: 43 additions & 12 deletions src/main/resources/db/changelog/changes/v1.2.0/changelog-v1.2.0.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,50 @@
<changeSet id="MODLISTS-123" author="[email protected]" runOnChange="true">
<comment>Update the canned lists to use the new entity type IDs and column names</comment>
<sql>
UPDATE list_details
SET entity_type_id = 'd0213d22-32cf-490f-9196-d81c3c66e53f',
fql_query = '{"items.status_name": {"$in": ["Missing", "Aged to lost", "Claimed returned", "Declared lost", "Long missing" ] }}',
user_friendly_query = 'items.status_name in [Missing, Aged to lost, Claimed returned, Declared lost, Long missing]'
WHERE id = '605a345f-f456-4ab2-8968-22f49cf1fbb6';
</sql>
INSERT INTO list_details
(id, name, description, entity_type_id, fql_query, fields, created_by, created_by_username, created_date, updated_by, updated_by_username, updated_date, is_active, is_private, is_canned, version, user_friendly_query)
values
('605a345f-f456-4ab2-8968-22f49cf1fbb6',
'Missing items',
'Returns all items with a status of: missing, aged to lost, claimed returned, declared lost, long missing',
'd0213d22-32cf-490f-9196-d81c3c66e53f',
'{"items.status_name": {"$in": ["Missing", "Aged to lost", "Claimed returned", "Declared lost", "Long missing" ] }}',
'{id, item_hrid, holdings_id, item_effective_call_number, item_effective_call_number_typeid, item_effective_call_number_type_name, item_holdings_record_id, item_status, item_copy_number, item_barcode, item_created_date, item_updated_date, item_effective_location_id, item_effective_location_name, item_effective_library_id, item_effective_library_name, item_effective_library_code, item_material_type_id, item_material_type, instance_id, instance_title, instance_created_date, instance_updated_date, instance_primary_contributor, item_level_call_number, item_level_call_number_typeid, item_permanent_location_id, item_temporary_location_id, item_level_call_number_type_name, item_permanent_location_name, item_temporary_location_name}',
'7eb41f7c-ec2f-4637-8ceb-2e9573666ad0',
'SYSTEM',
Now(),
'7eb41f7c-ec2f-4637-8ceb-2e9573666ad0',
'SYSTEM',
Now(),
true,
false,
true,
1,
'items.status_name in [Missing, Aged to lost, Claimed returned, Declared lost, Long missing]'),

('97f5829f-1510-47bc-8454-ae7fa849baef',
'Inactive patrons with open loans',
'Returns all inactive users with a loan status of open',
'd6729885-f2fb-4dc7-b7d0-a865a7f461e4',
'{"$and": [{"loans.status_name" : {"$eq": "Open"}}, {"users.active" : {"$eq": "false"}}]}',
'{user_id, user_first_name, user_last_name, user_full_name, user_active, user_barcode, user_expiration_date, user_patron_group_id, user_patron_group, id, loan_status, loan_checkout_date, loan_due_date, loan_policy_id, loan_policy_name, loan_checkout_servicepoint_id, loan_checkout_servicepoint_name, item_holdingsrecord_id, instance_id, instance_title, instance_primary_contributor, item_id, item_barcode, item_status, item_material_type_id, item_material_type}',
'7eb41f7c-ec2f-4637-8ceb-2e9573666ad0',
'SYSTEM',
Now(),
'7eb41f7c-ec2f-4637-8ceb-2e9573666ad0',
'SYSTEM',
Now(),
true,
false,
true,
1,
'(loans.status_name == Open) AND (users.active == false)')
ON CONFLICT (id) DO UPDATE SET name = EXCLUDED.name, description = EXCLUDED.description, entity_type_id = EXCLUDED.entity_type_id,
fql_query = EXCLUDED.fql_query, fields = EXCLUDED.fields, created_by = EXCLUDED.created_by, created_by_username = EXCLUDED.created_by_username,
created_date = EXCLUDED.created_date, updated_by = EXCLUDED.updated_by, updated_by_username = EXCLUDED.updated_by_username,
updated_date = EXCLUDED.updated_date, is_active = EXCLUDED.is_active, is_private = EXCLUDED.is_private, is_canned = EXCLUDED.is_canned,
version = EXCLUDED.version, user_friendly_query = EXCLUDED.user_friendly_query ;

<sql>
UPDATE list_details
SET entity_type_id = 'd6729885-f2fb-4dc7-b7d0-a865a7f461e4',
fql_query = '{"$and": [{"loans.status_name" : {"$eq": "Open"}}, {"users.active" : {"$eq": "false"}}]}',
user_friendly_query = '(loans.status_name == Open) AND (users.active == false)'
WHERE id = '97f5829f-1510-47bc-8454-ae7fa849baef';
</sql>
</changeSet>
</databaseChangeLog>

0 comments on commit d9bb192

Please sign in to comment.