Skip to content

Commit 0656f39

Browse files
chore: update script to update MARC bib field 590,subfields and indicators
1 parent 7260feb commit 0656f39

1 file changed

Lines changed: 21 additions & 7 deletions

File tree

mod-record-specifications-server/src/main/resources/db/scripts/20260520_update_marc_bib_590.sql

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,33 @@
33
-- Replace ${tenantId} placeholder with specific tenant id
44
SET SEARCH_PATH = ${tenantId}_mod_record_specifications;
55

6-
-- Update field '590' to be non-deprecated and make its subfield 'd' repeatable in the MARC bibliographic specification.
6+
-- Update field '590' to be non-deprecated and set scope to LOCAL in MARC bibliographic specification
77
WITH updated_field AS (
88
UPDATE field f
9-
SET deprecated = false
9+
SET deprecated = false,
10+
scope = 'LOCAL'
1011
FROM specification s
1112
WHERE f.specification_id = s.id
1213
AND f.tag = '590'
1314
AND s.family = 'MARC'::family_enum
1415
AND s.profile = 'BIBLIOGRAPHIC'::family_profile_enum
1516
RETURNING f.id
17+
),
18+
-- Update subfields of field '590' to set scope to LOCAL and make subfield 'd' repeatable
19+
updated_subfield AS (
20+
UPDATE subfield sf
21+
SET scope = 'LOCAL',
22+
repeatable = CASE
23+
WHEN sf.code = 'd' THEN true
24+
ELSE repeatable
25+
END
26+
FROM updated_field f
27+
WHERE sf.field_id = f.id
28+
RETURNING 1
1629
)
17-
UPDATE subfield sf
18-
SET repeatable = true
19-
FROM updated_field f
20-
WHERE sf.field_id = f.id
21-
AND sf.code = 'd';
30+
-- Update indicator codes of field '590' to set scope to LOCAL
31+
UPDATE indicator_code ic
32+
SET scope = 'LOCAL'
33+
FROM indicator i, updated_field f
34+
WHERE ic.indicator_id = i.id
35+
AND i.field_id = f.id;

0 commit comments

Comments
 (0)