Skip to content

Commit 2b22913

Browse files
chore: add script to update MARC bib field '590' (#222)
1 parent 6faba0e commit 2b22913

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
-- Script for https://folio-org.atlassian.net/browse/MRSPECS-202
2+
3+
-- Replace ${tenantId} placeholder with specific tenant id
4+
SET SEARCH_PATH = ${tenantId}_mod_record_specifications;
5+
6+
-- Update field '590' to be non-deprecated and set scope to LOCAL in MARC bibliographic specification
7+
WITH updated_field AS (
8+
UPDATE field f
9+
SET deprecated = false,
10+
scope = 'LOCAL'
11+
FROM specification s
12+
WHERE f.specification_id = s.id
13+
AND f.tag = '590'
14+
AND s.family = 'MARC'::family_enum
15+
AND s.profile = 'BIBLIOGRAPHIC'::family_profile_enum
16+
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
29+
)
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)