]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/sql/Pg/version-upgrade/3.2.5-3.3.0-upgrade-db.sql
LP#1772028 Add some FK violation functions just in case they are missing
[Evergreen.git] / Open-ILS / src / sql / Pg / version-upgrade / 3.2.5-3.3.0-upgrade-db.sql
1 --Upgrade Script for 3.2.5 to 3.3.0
2 \set eg_version '''3.3.0'''
3 BEGIN;
4 INSERT INTO config.upgrade_log (version, applied_to) VALUES ('3.3.0', :eg_version);
5
6 SELECT evergreen.upgrade_deps_block_check('1135', :eg_version);
7
8 CREATE OR REPLACE FUNCTION biblio.indexing_ingest_or_delete () RETURNS TRIGGER AS $func$
9 DECLARE
10     tmp_bool BOOL;
11 BEGIN
12
13     IF NEW.deleted THEN -- If this bib is deleted
14
15         PERFORM * FROM config.internal_flag WHERE
16             name = 'ingest.metarecord_mapping.preserve_on_delete' AND enabled;
17
18         tmp_bool := FOUND; -- Just in case this is changed by some other statement
19
20         PERFORM metabib.remap_metarecord_for_bib( NEW.id, NEW.fingerprint, TRUE, tmp_bool );
21
22         IF NOT tmp_bool THEN
23             -- One needs to keep these around to support searches
24             -- with the #deleted modifier, so one should turn on the named
25             -- internal flag for that functionality.
26             DELETE FROM metabib.record_attr_vector_list WHERE source = NEW.id;
27         END IF;
28
29         DELETE FROM authority.bib_linking WHERE bib = NEW.id; -- Avoid updating fields in bibs that are no longer visible
30         DELETE FROM biblio.peer_bib_copy_map WHERE peer_record = NEW.id; -- Separate any multi-homed items
31         DELETE FROM metabib.browse_entry_def_map WHERE source = NEW.id; -- Don't auto-suggest deleted bibs
32         RETURN NEW; -- and we're done
33     END IF;
34
35     IF TG_OP = 'UPDATE' AND OLD.deleted IS FALSE THEN -- re-ingest?
36         PERFORM * FROM config.internal_flag WHERE name = 'ingest.reingest.force_on_same_marc' AND enabled;
37
38         IF NOT FOUND AND OLD.marc = NEW.marc THEN -- don't do anything if the MARC didn't change
39             RETURN NEW;
40         END IF;
41     END IF;
42
43     -- Record authority linking
44     PERFORM * FROM config.internal_flag WHERE name = 'ingest.disable_authority_linking' AND enabled;
45     IF NOT FOUND THEN
46         PERFORM biblio.map_authority_linking( NEW.id, NEW.marc );
47     END IF;
48
49     -- Flatten and insert the mfr data
50     PERFORM * FROM config.internal_flag WHERE name = 'ingest.disable_metabib_full_rec' AND enabled;
51     IF NOT FOUND THEN
52         PERFORM metabib.reingest_metabib_full_rec(NEW.id);
53
54         -- Now we pull out attribute data, which is dependent on the mfr for all but XPath-based fields
55         PERFORM * FROM config.internal_flag WHERE name = 'ingest.disable_metabib_rec_descriptor' AND enabled;
56         IF NOT FOUND THEN
57             PERFORM metabib.reingest_record_attributes(NEW.id, NULL, NEW.marc, TG_OP = 'INSERT' OR OLD.deleted);
58         END IF;
59     END IF;
60
61     -- Gather and insert the field entry data
62     PERFORM metabib.reingest_metabib_field_entries(NEW.id);
63
64     -- Located URI magic
65     PERFORM * FROM config.internal_flag WHERE name = 'ingest.disable_located_uri' AND enabled;
66     IF NOT FOUND THEN PERFORM biblio.extract_located_uris( NEW.id, NEW.marc, NEW.editor ); END IF;
67
68     -- (re)map metarecord-bib linking
69     IF TG_OP = 'INSERT' THEN -- if not deleted and performing an insert, check for the flag
70         PERFORM * FROM config.internal_flag WHERE name = 'ingest.metarecord_mapping.skip_on_insert' AND enabled;
71         IF NOT FOUND THEN
72             PERFORM metabib.remap_metarecord_for_bib( NEW.id, NEW.fingerprint );
73         END IF;
74     ELSE -- we're doing an update, and we're not deleted, remap
75         PERFORM * FROM config.internal_flag WHERE name = 'ingest.metarecord_mapping.skip_on_update' AND enabled;
76         IF NOT FOUND THEN
77             PERFORM metabib.remap_metarecord_for_bib( NEW.id, NEW.fingerprint );
78         END IF;
79     END IF;
80
81     RETURN NEW;
82 END;
83 $func$ LANGUAGE PLPGSQL;
84
85
86
87
88 SELECT evergreen.upgrade_deps_block_check('1139', :eg_version);
89
90 ALTER TABLE actor.usr ADD COLUMN guardian TEXT;
91
92 CREATE INDEX actor_usr_guardian_idx 
93     ON actor.usr (evergreen.lowercase(guardian));
94 CREATE INDEX actor_usr_guardian_unaccent_idx 
95     ON actor.usr (evergreen.unaccent_and_squash(guardian));
96
97 -- Modify auditor tables accordingly.
98 SELECT auditor.update_auditors();
99
100 -- clear the guardian field on delete
101 CREATE OR REPLACE FUNCTION actor.usr_delete(
102         src_usr  IN INTEGER,
103         dest_usr IN INTEGER
104 ) RETURNS VOID AS $$
105 DECLARE
106         old_profile actor.usr.profile%type;
107         old_home_ou actor.usr.home_ou%type;
108         new_profile actor.usr.profile%type;
109         new_home_ou actor.usr.home_ou%type;
110         new_name    text;
111         new_dob     actor.usr.dob%type;
112 BEGIN
113         SELECT
114                 id || '-PURGED-' || now(),
115                 profile,
116                 home_ou,
117                 dob
118         INTO
119                 new_name,
120                 old_profile,
121                 old_home_ou,
122                 new_dob
123         FROM
124                 actor.usr
125         WHERE
126                 id = src_usr;
127         --
128         -- Quit if no such user
129         --
130         IF old_profile IS NULL THEN
131                 RETURN;
132         END IF;
133         --
134         perform actor.usr_purge_data( src_usr, dest_usr );
135         --
136         -- Find the root grp_tree and the root org_unit.  This would be simpler if we 
137         -- could assume that there is only one root.  Theoretically, someday, maybe,
138         -- there could be multiple roots, so we take extra trouble to get the right ones.
139         --
140         SELECT
141                 id
142         INTO
143                 new_profile
144         FROM
145                 permission.grp_ancestors( old_profile )
146         WHERE
147                 parent is null;
148         --
149         SELECT
150                 id
151         INTO
152                 new_home_ou
153         FROM
154                 actor.org_unit_ancestors( old_home_ou )
155         WHERE
156                 parent_ou is null;
157         --
158         -- Truncate date of birth
159         --
160         IF new_dob IS NOT NULL THEN
161                 new_dob := date_trunc( 'year', new_dob );
162         END IF;
163         --
164         UPDATE
165                 actor.usr
166                 SET
167                         card = NULL,
168                         profile = new_profile,
169                         usrname = new_name,
170                         email = NULL,
171                         passwd = random()::text,
172                         standing = DEFAULT,
173                         ident_type = 
174                         (
175                                 SELECT MIN( id )
176                                 FROM config.identification_type
177                         ),
178                         ident_value = NULL,
179                         ident_type2 = NULL,
180                         ident_value2 = NULL,
181                         net_access_level = DEFAULT,
182                         photo_url = NULL,
183                         prefix = NULL,
184                         first_given_name = new_name,
185                         guardian = NULL,
186                         family_name = new_name,
187                         suffix = NULL,
188                         alias = NULL,
189             guardian = NULL,
190                         day_phone = NULL,
191                         evening_phone = NULL,
192                         other_phone = NULL,
193                         mailing_address = NULL,
194                         billing_address = NULL,
195                         home_ou = new_home_ou,
196                         dob = new_dob,
197                         active = FALSE,
198                         master_account = DEFAULT, 
199                         super_user = DEFAULT,
200                         barred = FALSE,
201                         deleted = TRUE,
202                         juvenile = DEFAULT,
203                         usrgroup = 0,
204                         claims_returned_count = DEFAULT,
205                         credit_forward_balance = DEFAULT,
206                         last_xact_id = DEFAULT,
207                         alert_message = NULL,
208                         create_date = now(),
209                         expire_date = now()
210         WHERE
211                 id = src_usr;
212 END;
213 $$ LANGUAGE plpgsql;
214
215 INSERT into config.org_unit_setting_type (name, label, description, datatype) 
216 VALUES ( 
217     'ui.patron.edit.au.guardian.show',
218     oils_i18n_gettext(
219         'ui.patron.edit.au.guardian.show', 
220         'GUI: Show guardian field on patron registration', 
221         'coust', 'label'
222     ),
223     oils_i18n_gettext(
224         'ui.patron.edit.au.guardian.show', 
225         'The guardian field will be shown on the patron registration screen. Showing a field makes it appear with required fields even when not required. If the field is required this setting is ignored.', 
226         'coust', 'description'
227     ),
228     'bool'
229 ), (
230     'ui.patron.edit.au.guardian.suggest',
231     oils_i18n_gettext(
232         'ui.patron.edit.au.guardian.suggest', 
233         'GUI: Suggest guardian field on patron registration', 
234         'coust', 'label'
235     ),
236     oils_i18n_gettext(
237         'ui.patron.edit.au.guardian.suggest', 
238         'The guardian field will be suggested on the patron registration screen. Suggesting a field makes it appear when suggested fields are shown. If the field is shown or required this setting is ignored.', 
239         'coust', 'description'),
240     'bool'
241 ), (
242     'ui.patron.edit.guardian_required_for_juv',
243     oils_i18n_gettext(
244         'ui.patron.edit.guardian_required_for_juv',
245         'GUI: Juvenile account requires parent/guardian',
246         'coust', 'label'
247     ),
248     oils_i18n_gettext(
249         'ui.patron.edit.guardian_required_for_juv',
250         'Require a value for the parent/guardian field in the patron editor for patrons marked as juvenile',
251         'coust', 'description'),
252     'bool'
253 );
254
255
256
257
258 SELECT evergreen.upgrade_deps_block_check('1140', :eg_version);
259
260 DROP FUNCTION IF EXISTS evergreen.org_top();
261
262 CREATE OR REPLACE FUNCTION evergreen.org_top()
263 RETURNS actor.org_unit AS $$
264     SELECT * FROM actor.org_unit WHERE parent_ou IS NULL LIMIT 1;
265 $$ LANGUAGE SQL STABLE;
266
267
268 SELECT evergreen.upgrade_deps_block_check('1143', :eg_version);
269
270 INSERT into config.workstation_setting_type (name, grp, datatype, label)
271 VALUES (
272     'eg.grid.admin.booking.resource', 'gui', 'object',
273     oils_i18n_gettext (
274         'eg.grid.admin.booking.resource',
275         'Grid Config: admin.booking.resource',
276         'cwst', 'label'
277     )
278 ), (
279     'eg.grid.admin.booking.resource_attr', 'gui', 'object',
280     oils_i18n_gettext (
281     'eg.grid.admin.booking.resource_attr',
282         'Grid Config: admin.booking.resource_attr',
283         'cwst', 'label'
284     )
285 ), (
286     'eg.grid.admin.booking.resource_attr_map', 'gui', 'object',
287     oils_i18n_gettext (
288     'eg.grid.admin.booking.resource_attr_map',
289         'Grid Config: admin.booking.resource_attr_map',
290         'cwst', 'label'
291     )
292 ), (
293     'eg.grid.admin.booking.resource_attr_value', 'gui', 'object',
294     oils_i18n_gettext (
295     'eg.grid.admin.booking.resource_attr_value',
296         'Grid Config: admin.booking.resource_attr_value',
297         'cwst', 'label'
298     )
299 ), (
300     'eg.grid.admin.booking.resource_type', 'gui', 'object',
301     oils_i18n_gettext (
302     'eg.grid.admin.booking.resource_type',
303         'Grid Config: admin.booking.resource_type',
304         'cwst', 'label'
305     )
306 );
307
308
309 INSERT INTO config.upgrade_log (version) VALUES ('1144');
310
311 CREATE TABLE actor.usr_privacy_waiver (
312     id BIGSERIAL PRIMARY KEY,
313     usr BIGINT NOT NULL REFERENCES actor.usr(id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
314     name TEXT NOT NULL,
315     place_holds BOOL DEFAULT FALSE,
316     pickup_holds BOOL DEFAULT FALSE,
317     view_history BOOL DEFAULT FALSE,
318     checkout_items BOOL DEFAULT FALSE
319 );
320 CREATE INDEX actor_usr_privacy_waiver_usr_idx ON actor.usr_privacy_waiver (usr);
321
322
323
324 INSERT INTO config.upgrade_log (version) VALUES ('1145');
325
326 CREATE OR REPLACE FUNCTION actor.usr_purge_data(
327         src_usr  IN INTEGER,
328         specified_dest_usr IN INTEGER
329 ) RETURNS VOID AS $$
330 DECLARE
331         suffix TEXT;
332         renamable_row RECORD;
333         dest_usr INTEGER;
334 BEGIN
335
336         IF specified_dest_usr IS NULL THEN
337                 dest_usr := 1; -- Admin user on stock installs
338         ELSE
339                 dest_usr := specified_dest_usr;
340         END IF;
341
342         -- acq.*
343         UPDATE acq.fund_allocation SET allocator = dest_usr WHERE allocator = src_usr;
344         UPDATE acq.lineitem SET creator = dest_usr WHERE creator = src_usr;
345         UPDATE acq.lineitem SET editor = dest_usr WHERE editor = src_usr;
346         UPDATE acq.lineitem SET selector = dest_usr WHERE selector = src_usr;
347         UPDATE acq.lineitem_note SET creator = dest_usr WHERE creator = src_usr;
348         UPDATE acq.lineitem_note SET editor = dest_usr WHERE editor = src_usr;
349     UPDATE acq.invoice SET closed_by = dest_usr WHERE closed_by = src_usr;
350         DELETE FROM acq.lineitem_usr_attr_definition WHERE usr = src_usr;
351
352         -- Update with a rename to avoid collisions
353         FOR renamable_row in
354                 SELECT id, name
355                 FROM   acq.picklist
356                 WHERE  owner = src_usr
357         LOOP
358                 suffix := ' (' || src_usr || ')';
359                 LOOP
360                         BEGIN
361                                 UPDATE  acq.picklist
362                                 SET     owner = dest_usr, name = name || suffix
363                                 WHERE   id = renamable_row.id;
364                         EXCEPTION WHEN unique_violation THEN
365                                 suffix := suffix || ' ';
366                                 CONTINUE;
367                         END;
368                         EXIT;
369                 END LOOP;
370         END LOOP;
371
372         UPDATE acq.picklist SET creator = dest_usr WHERE creator = src_usr;
373         UPDATE acq.picklist SET editor = dest_usr WHERE editor = src_usr;
374         UPDATE acq.po_note SET creator = dest_usr WHERE creator = src_usr;
375         UPDATE acq.po_note SET editor = dest_usr WHERE editor = src_usr;
376         UPDATE acq.purchase_order SET owner = dest_usr WHERE owner = src_usr;
377         UPDATE acq.purchase_order SET creator = dest_usr WHERE creator = src_usr;
378         UPDATE acq.purchase_order SET editor = dest_usr WHERE editor = src_usr;
379         UPDATE acq.claim_event SET creator = dest_usr WHERE creator = src_usr;
380
381         -- action.*
382         DELETE FROM action.circulation WHERE usr = src_usr;
383         UPDATE action.circulation SET circ_staff = dest_usr WHERE circ_staff = src_usr;
384         UPDATE action.circulation SET checkin_staff = dest_usr WHERE checkin_staff = src_usr;
385         UPDATE action.hold_notification SET notify_staff = dest_usr WHERE notify_staff = src_usr;
386         UPDATE action.hold_request SET fulfillment_staff = dest_usr WHERE fulfillment_staff = src_usr;
387         UPDATE action.hold_request SET requestor = dest_usr WHERE requestor = src_usr;
388         DELETE FROM action.hold_request WHERE usr = src_usr;
389         UPDATE action.in_house_use SET staff = dest_usr WHERE staff = src_usr;
390         UPDATE action.non_cat_in_house_use SET staff = dest_usr WHERE staff = src_usr;
391         DELETE FROM action.non_cataloged_circulation WHERE patron = src_usr;
392         UPDATE action.non_cataloged_circulation SET staff = dest_usr WHERE staff = src_usr;
393         DELETE FROM action.survey_response WHERE usr = src_usr;
394         UPDATE action.fieldset SET owner = dest_usr WHERE owner = src_usr;
395         DELETE FROM action.usr_circ_history WHERE usr = src_usr;
396
397         -- actor.*
398         DELETE FROM actor.card WHERE usr = src_usr;
399         DELETE FROM actor.stat_cat_entry_usr_map WHERE target_usr = src_usr;
400         DELETE FROM actor.usr_privacy_waiver WHERE usr = src_usr;
401
402         -- The following update is intended to avoid transient violations of a foreign
403         -- key constraint, whereby actor.usr_address references itself.  It may not be
404         -- necessary, but it does no harm.
405         UPDATE actor.usr_address SET replaces = NULL
406                 WHERE usr = src_usr AND replaces IS NOT NULL;
407         DELETE FROM actor.usr_address WHERE usr = src_usr;
408         DELETE FROM actor.usr_note WHERE usr = src_usr;
409         UPDATE actor.usr_note SET creator = dest_usr WHERE creator = src_usr;
410         DELETE FROM actor.usr_org_unit_opt_in WHERE usr = src_usr;
411         UPDATE actor.usr_org_unit_opt_in SET staff = dest_usr WHERE staff = src_usr;
412         DELETE FROM actor.usr_setting WHERE usr = src_usr;
413         DELETE FROM actor.usr_standing_penalty WHERE usr = src_usr;
414         UPDATE actor.usr_standing_penalty SET staff = dest_usr WHERE staff = src_usr;
415
416         -- asset.*
417         UPDATE asset.call_number SET creator = dest_usr WHERE creator = src_usr;
418         UPDATE asset.call_number SET editor = dest_usr WHERE editor = src_usr;
419         UPDATE asset.call_number_note SET creator = dest_usr WHERE creator = src_usr;
420         UPDATE asset.copy SET creator = dest_usr WHERE creator = src_usr;
421         UPDATE asset.copy SET editor = dest_usr WHERE editor = src_usr;
422         UPDATE asset.copy_note SET creator = dest_usr WHERE creator = src_usr;
423
424         -- auditor.*
425         DELETE FROM auditor.actor_usr_address_history WHERE id = src_usr;
426         DELETE FROM auditor.actor_usr_history WHERE id = src_usr;
427         UPDATE auditor.asset_call_number_history SET creator = dest_usr WHERE creator = src_usr;
428         UPDATE auditor.asset_call_number_history SET editor  = dest_usr WHERE editor  = src_usr;
429         UPDATE auditor.asset_copy_history SET creator = dest_usr WHERE creator = src_usr;
430         UPDATE auditor.asset_copy_history SET editor  = dest_usr WHERE editor  = src_usr;
431         UPDATE auditor.biblio_record_entry_history SET creator = dest_usr WHERE creator = src_usr;
432         UPDATE auditor.biblio_record_entry_history SET editor  = dest_usr WHERE editor  = src_usr;
433
434         -- biblio.*
435         UPDATE biblio.record_entry SET creator = dest_usr WHERE creator = src_usr;
436         UPDATE biblio.record_entry SET editor = dest_usr WHERE editor = src_usr;
437         UPDATE biblio.record_note SET creator = dest_usr WHERE creator = src_usr;
438         UPDATE biblio.record_note SET editor = dest_usr WHERE editor = src_usr;
439
440         -- container.*
441         -- Update buckets with a rename to avoid collisions
442         FOR renamable_row in
443                 SELECT id, name
444                 FROM   container.biblio_record_entry_bucket
445                 WHERE  owner = src_usr
446         LOOP
447                 suffix := ' (' || src_usr || ')';
448                 LOOP
449                         BEGIN
450                                 UPDATE  container.biblio_record_entry_bucket
451                                 SET     owner = dest_usr, name = name || suffix
452                                 WHERE   id = renamable_row.id;
453                         EXCEPTION WHEN unique_violation THEN
454                                 suffix := suffix || ' ';
455                                 CONTINUE;
456                         END;
457                         EXIT;
458                 END LOOP;
459         END LOOP;
460
461         FOR renamable_row in
462                 SELECT id, name
463                 FROM   container.call_number_bucket
464                 WHERE  owner = src_usr
465         LOOP
466                 suffix := ' (' || src_usr || ')';
467                 LOOP
468                         BEGIN
469                                 UPDATE  container.call_number_bucket
470                                 SET     owner = dest_usr, name = name || suffix
471                                 WHERE   id = renamable_row.id;
472                         EXCEPTION WHEN unique_violation THEN
473                                 suffix := suffix || ' ';
474                                 CONTINUE;
475                         END;
476                         EXIT;
477                 END LOOP;
478         END LOOP;
479
480         FOR renamable_row in
481                 SELECT id, name
482                 FROM   container.copy_bucket
483                 WHERE  owner = src_usr
484         LOOP
485                 suffix := ' (' || src_usr || ')';
486                 LOOP
487                         BEGIN
488                                 UPDATE  container.copy_bucket
489                                 SET     owner = dest_usr, name = name || suffix
490                                 WHERE   id = renamable_row.id;
491                         EXCEPTION WHEN unique_violation THEN
492                                 suffix := suffix || ' ';
493                                 CONTINUE;
494                         END;
495                         EXIT;
496                 END LOOP;
497         END LOOP;
498
499         FOR renamable_row in
500                 SELECT id, name
501                 FROM   container.user_bucket
502                 WHERE  owner = src_usr
503         LOOP
504                 suffix := ' (' || src_usr || ')';
505                 LOOP
506                         BEGIN
507                                 UPDATE  container.user_bucket
508                                 SET     owner = dest_usr, name = name || suffix
509                                 WHERE   id = renamable_row.id;
510                         EXCEPTION WHEN unique_violation THEN
511                                 suffix := suffix || ' ';
512                                 CONTINUE;
513                         END;
514                         EXIT;
515                 END LOOP;
516         END LOOP;
517
518         DELETE FROM container.user_bucket_item WHERE target_user = src_usr;
519
520         -- money.*
521         DELETE FROM money.billable_xact WHERE usr = src_usr;
522         DELETE FROM money.collections_tracker WHERE usr = src_usr;
523         UPDATE money.collections_tracker SET collector = dest_usr WHERE collector = src_usr;
524
525         -- permission.*
526         DELETE FROM permission.usr_grp_map WHERE usr = src_usr;
527         DELETE FROM permission.usr_object_perm_map WHERE usr = src_usr;
528         DELETE FROM permission.usr_perm_map WHERE usr = src_usr;
529         DELETE FROM permission.usr_work_ou_map WHERE usr = src_usr;
530
531         -- reporter.*
532         -- Update with a rename to avoid collisions
533         BEGIN
534                 FOR renamable_row in
535                         SELECT id, name
536                         FROM   reporter.output_folder
537                         WHERE  owner = src_usr
538                 LOOP
539                         suffix := ' (' || src_usr || ')';
540                         LOOP
541                                 BEGIN
542                                         UPDATE  reporter.output_folder
543                                         SET     owner = dest_usr, name = name || suffix
544                                         WHERE   id = renamable_row.id;
545                                 EXCEPTION WHEN unique_violation THEN
546                                         suffix := suffix || ' ';
547                                         CONTINUE;
548                                 END;
549                                 EXIT;
550                         END LOOP;
551                 END LOOP;
552         EXCEPTION WHEN undefined_table THEN
553                 -- do nothing
554         END;
555
556         BEGIN
557                 UPDATE reporter.report SET owner = dest_usr WHERE owner = src_usr;
558         EXCEPTION WHEN undefined_table THEN
559                 -- do nothing
560         END;
561
562         -- Update with a rename to avoid collisions
563         BEGIN
564                 FOR renamable_row in
565                         SELECT id, name
566                         FROM   reporter.report_folder
567                         WHERE  owner = src_usr
568                 LOOP
569                         suffix := ' (' || src_usr || ')';
570                         LOOP
571                                 BEGIN
572                                         UPDATE  reporter.report_folder
573                                         SET     owner = dest_usr, name = name || suffix
574                                         WHERE   id = renamable_row.id;
575                                 EXCEPTION WHEN unique_violation THEN
576                                         suffix := suffix || ' ';
577                                         CONTINUE;
578                                 END;
579                                 EXIT;
580                         END LOOP;
581                 END LOOP;
582         EXCEPTION WHEN undefined_table THEN
583                 -- do nothing
584         END;
585
586         BEGIN
587                 UPDATE reporter.schedule SET runner = dest_usr WHERE runner = src_usr;
588         EXCEPTION WHEN undefined_table THEN
589                 -- do nothing
590         END;
591
592         BEGIN
593                 UPDATE reporter.template SET owner = dest_usr WHERE owner = src_usr;
594         EXCEPTION WHEN undefined_table THEN
595                 -- do nothing
596         END;
597
598         -- Update with a rename to avoid collisions
599         BEGIN
600                 FOR renamable_row in
601                         SELECT id, name
602                         FROM   reporter.template_folder
603                         WHERE  owner = src_usr
604                 LOOP
605                         suffix := ' (' || src_usr || ')';
606                         LOOP
607                                 BEGIN
608                                         UPDATE  reporter.template_folder
609                                         SET     owner = dest_usr, name = name || suffix
610                                         WHERE   id = renamable_row.id;
611                                 EXCEPTION WHEN unique_violation THEN
612                                         suffix := suffix || ' ';
613                                         CONTINUE;
614                                 END;
615                                 EXIT;
616                         END LOOP;
617                 END LOOP;
618         EXCEPTION WHEN undefined_table THEN
619         -- do nothing
620         END;
621
622         -- vandelay.*
623         -- Update with a rename to avoid collisions
624         FOR renamable_row in
625                 SELECT id, name
626                 FROM   vandelay.queue
627                 WHERE  owner = src_usr
628         LOOP
629                 suffix := ' (' || src_usr || ')';
630                 LOOP
631                         BEGIN
632                                 UPDATE  vandelay.queue
633                                 SET     owner = dest_usr, name = name || suffix
634                                 WHERE   id = renamable_row.id;
635                         EXCEPTION WHEN unique_violation THEN
636                                 suffix := suffix || ' ';
637                                 CONTINUE;
638                         END;
639                         EXIT;
640                 END LOOP;
641         END LOOP;
642
643     UPDATE vandelay.session_tracker SET usr = dest_usr WHERE usr = src_usr;
644
645     -- NULL-ify addresses last so other cleanup (e.g. circ anonymization)
646     -- can access the information before deletion.
647         UPDATE actor.usr SET
648                 active = FALSE,
649                 card = NULL,
650                 mailing_address = NULL,
651                 billing_address = NULL
652         WHERE id = src_usr;
653
654 END;
655 $$ LANGUAGE plpgsql;
656
657 COMMENT ON FUNCTION actor.usr_purge_data(INT, INT) IS $$
658 Finds rows dependent on a given row in actor.usr and either deletes them
659 or reassigns them to a different user.
660 $$;
661
662
663
664 SELECT evergreen.upgrade_deps_block_check('1146', :eg_version);
665
666 INSERT INTO config.org_unit_setting_type
667     (name, label, description, grp, datatype)
668     VALUES (
669         'circ.privacy_waiver',
670         oils_i18n_gettext('circ.privacy_waiver',
671             'Allow others to use patron account (privacy waiver)',
672             'coust', 'label'),
673         oils_i18n_gettext('circ.privacy_waiver',
674             'Add a note to a user account indicating that specified people are allowed to ' ||
675             'place holds, pick up holds, check out items, or view borrowing history for that user account',
676             'coust', 'description'),
677         'circ',
678         'bool'
679     );
680
681
682
683 SELECT evergreen.upgrade_deps_block_check('1147', :eg_version);
684
685 INSERT INTO config.workstation_setting_type (name, grp, datatype, label)
686 VALUES (
687     'eg.grid.admin.server.config.rule_age_hold_protect', 'gui', 'object',
688     oils_i18n_gettext(
689         'eg.grid.admin.server.config.rule_age_hold_protect',
690         'Grid Config: admin.server.config.rule_age_hold_protect',
691         'cwst', 'label'
692     )
693 ), (
694     'eg.grid.admin.server.asset.stat_cat_sip_fields', 'gui', 'object',
695     oils_i18n_gettext(
696         'eg.grid.admin.server.asset.stat_cat_sip_fields',
697         'Grid Config: admin.server.asset.stat_cat_sip_fields',
698         'cwst', 'label'
699     )
700 ), (
701     'eg.grid.admin.server.actor.stat_cat_sip_fields', 'gui', 'object',
702     oils_i18n_gettext(
703         'eg.grid.admin.server.actor.stat_cat_sip_fields',
704         'Grid Config: admin.server.actor.stat_cat_sip_fields',
705         'cwst', 'label'
706     )
707 ), (
708     'eg.grid.admin.server.authority.browse_axis', 'gui', 'object',
709     oils_i18n_gettext(
710         'eg.grid.admin.server.authority.browse_axis',
711         'Grid Config: admin.server.authority.browse_axis',
712         'cwst', 'label'
713     )
714 ), (
715     'eg.grid.admin.server.authority.control_set', 'gui', 'object',
716     oils_i18n_gettext(
717         'eg.grid.admin.server.authority.control_set',
718         'Grid Config: admin.server.authority.control_set',
719         'cwst', 'label'
720     )
721 ), (
722     'eg.grid.admin.server.authority.heading_field', 'gui', 'object',
723     oils_i18n_gettext(
724         'eg.grid.admin.server.authority.heading_field',
725         'Grid Config: admin.server.authority.heading_field',
726         'cwst', 'label'
727     )
728 ), (
729     'eg.grid.admin.server.authority.thesaurus', 'gui', 'object',
730     oils_i18n_gettext(
731         'eg.grid.admin.server.authority.thesaurus',
732         'Grid Config: admin.server.authority.thesaurus',
733         'cwst', 'label'
734     )
735 ), (
736     'eg.grid.admin.server.config.best_hold_order', 'gui', 'object',
737     oils_i18n_gettext(
738         'eg.grid.admin.server.config.best_hold_order',
739         'Grid Config: admin.server.config.best_hold_order',
740         'cwst', 'label'
741     )
742 ), (
743     'eg.grid.admin.server.config.billing_type', 'gui', 'object',
744     oils_i18n_gettext(
745         'eg.grid.admin.server.config.billing_type',
746         'Grid Config: admin.server.config.billing_type',
747         'cwst', 'label'
748     )
749 ), (
750     'eg.grid.admin.server.asset.call_number_prefix', 'gui', 'object',
751     oils_i18n_gettext(
752         'eg.grid.admin.server.asset.call_number_prefix',
753         'Grid Config: admin.server.asset.call_number_prefix',
754         'cwst', 'label'
755     )
756 ), (
757     'eg.grid.admin.server.asset.call_number_suffix', 'gui', 'object',
758     oils_i18n_gettext(
759         'eg.grid.admin.server.asset.call_number_suffix',
760         'Grid Config: admin.server.asset.call_number_suffix',
761         'cwst', 'label'
762     )
763 ), (
764     'eg.grid.admin.server.config.rule_circ_duration', 'gui', 'object',
765     oils_i18n_gettext(
766         'eg.grid.admin.server.config.rule_circ_duration',
767         'Grid Config: admin.server.config.rule_circ_duration',
768         'cwst', 'label'
769     )
770 ), (
771     'eg.grid.admin.server.config.circ_limit_group', 'gui', 'object',
772     oils_i18n_gettext(
773         'eg.grid.admin.server.config.circ_limit_group',
774         'Grid Config: admin.server.config.circ_limit_group',
775         'cwst', 'label'
776     )
777 ), (
778     'eg.grid.admin.server.config.circ_matrix_weights', 'gui', 'object',
779     oils_i18n_gettext(
780         'eg.grid.admin.server.config.circ_matrix_weights',
781         'Grid Config: admin.server.config.circ_matrix_weights',
782         'cwst', 'label'
783     )
784 ), (
785     'eg.grid.admin.server.config.rule_max_fine', 'gui', 'object',
786     oils_i18n_gettext(
787         'eg.grid.admin.server.config.rule_max_fine',
788         'Grid Config: admin.server.config.rule_max_fine',
789         'cwst', 'label'
790     )
791 ), (
792     'eg.grid.admin.server.config.circ_modifier', 'gui', 'object',
793     oils_i18n_gettext(
794         'eg.grid.admin.server.config.circ_modifier',
795         'Grid Config: admin.server.config.circ_modifier',
796         'cwst', 'label'
797     )
798 ), (
799     'eg.grid.admin.server.config.copy_status', 'gui', 'object',
800     oils_i18n_gettext(
801         'eg.grid.admin.server.config.copy_status',
802         'Grid Config: admin.server.config.copy_status',
803         'cwst', 'label'
804     )
805 ), (
806     'eg.grid.admin.server.config.floating_group', 'gui', 'object',
807     oils_i18n_gettext(
808         'eg.grid.admin.server.config.floating_group',
809         'Grid Config: admin.server.config.floating_group',
810         'cwst', 'label'
811     )
812 ), (
813     'eg.grid.admin.server.config.global_flag', 'gui', 'object',
814     oils_i18n_gettext(
815         'eg.grid.admin.server.config.global_flag',
816         'Grid Config: admin.server.config.global_flag',
817         'cwst', 'label'
818     )
819 ), (
820     'eg.grid.admin.server.config.hard_due_date', 'gui', 'object',
821     oils_i18n_gettext(
822         'eg.grid.admin.server.config.hard_due_date',
823         'Grid Config: admin.server.config.hard_due_date',
824         'cwst', 'label'
825     )
826 ), (
827     'eg.grid.admin.server.config.hold_matrix_weights', 'gui', 'object',
828     oils_i18n_gettext(
829         'eg.grid.admin.server.config.hold_matrix_weights',
830         'Grid Config: admin.server.config.hold_matrix_weights',
831         'cwst', 'label'
832     )
833 ), (
834     'eg.grid.admin.server.vandelay.match_set', 'gui', 'object',
835     oils_i18n_gettext(
836         'eg.grid.admin.server.vandelay.match_set',
837         'Grid Config: admin.server.vandelay.match_set',
838         'cwst', 'label'
839     )
840 ), (
841     'eg.grid.admin.server.config.coded_value_map', 'gui', 'object',
842     oils_i18n_gettext(
843         'eg.grid.admin.server.config.coded_value_map',
844         'Grid Config: admin.server.config.coded_value_map',
845         'cwst', 'label'
846     )
847 ), (
848     'eg.grid.admin.server.vandelay.import_bib_trash_group', 'gui', 'object',
849     oils_i18n_gettext(
850         'eg.grid.admin.server.vandelay.import_bib_trash_group',
851         'Grid Config: admin.server.vandelay.import_bib_trash_group',
852         'cwst', 'label'
853     )
854 ), (
855     'eg.grid.admin.server.config.record_attr_definition', 'gui', 'object',
856     oils_i18n_gettext(
857         'eg.grid.admin.server.config.record_attr_definition',
858         'Grid Config: admin.server.config.record_attr_definition',
859         'cwst', 'label'
860     )
861 ), (
862     'eg.grid.admin.server.config.metabib_class', 'gui', 'object',
863     oils_i18n_gettext(
864         'eg.grid.admin.server.config.metabib_class',
865         'Grid Config: admin.server.config.metabib_class',
866         'cwst', 'label'
867     )
868 ), (
869     'eg.grid.admin.server.config.metabib_field_ts_map', 'gui', 'object',
870     oils_i18n_gettext(
871         'eg.grid.admin.server.config.metabib_field_ts_map',
872         'Grid Config: admin.server.config.metabib_field_ts_map',
873         'cwst', 'label'
874     )
875 ), (
876     'eg.grid.admin.server.config.metabib_field', 'gui', 'object',
877     oils_i18n_gettext(
878         'eg.grid.admin.server.config.metabib_field',
879         'Grid Config: admin.server.config.metabib_field',
880         'cwst', 'label'
881     )
882 ), (
883     'eg.grid.admin.server.permission.perm_list', 'gui', 'object',
884     oils_i18n_gettext(
885         'eg.grid.admin.server.permission.perm_list',
886         'Grid Config: admin.server.permission.perm_list',
887         'cwst', 'label'
888     )
889 ), (
890     'eg.grid.admin.server.config.remote_account', 'gui', 'object',
891     oils_i18n_gettext(
892         'eg.grid.admin.server.config.remote_account',
893         'Grid Config: admin.server.config.remote_account',
894         'cwst', 'label'
895     )
896 ), (
897     'eg.grid.admin.server.config.sms_carrier', 'gui', 'object',
898     oils_i18n_gettext(
899         'eg.grid.admin.server.config.sms_carrier',
900         'Grid Config: admin.server.config.sms_carrier',
901         'cwst', 'label'
902     )
903 ), (
904     'eg.grid.admin.server.config.usr_activity_type', 'gui', 'object',
905     oils_i18n_gettext(
906         'eg.grid.admin.server.config.usr_activity_type',
907         'Grid Config: admin.server.config.usr_activity_type',
908         'cwst', 'label'
909     )
910 ), (
911     'eg.grid.admin.server.config.weight_assoc', 'gui', 'object',
912     oils_i18n_gettext(
913         'eg.grid.admin.server.config.weight_assoc',
914         'Grid Config: admin.server.config.weight_assoc',
915         'cwst', 'label'
916     )
917 ), (
918     'eg.grid.admin.server.config.z3950_index_field_map', 'gui', 'object',
919     oils_i18n_gettext(
920         'eg.grid.admin.server.config.z3950_index_field_map',
921         'Grid Config: admin.server.config.z3950_index_field_map',
922         'cwst', 'label'
923     )
924 ), (
925     'eg.grid.admin.server.config.z3950_source', 'gui', 'object',
926     oils_i18n_gettext(
927         'eg.grid.admin.server.config.z3950_source',
928         'Grid Config: admin.server.config.z3950_source',
929         'cwst', 'label'
930     )
931 );
932
933
934
935
936 SELECT evergreen.upgrade_deps_block_check('1148', :eg_version); -- csharp/gmcharlt
937
938 CREATE OR REPLACE FUNCTION actor.usr_delete(
939         src_usr  IN INTEGER,
940         dest_usr IN INTEGER
941 ) RETURNS VOID AS $$
942 DECLARE
943         old_profile actor.usr.profile%type;
944         old_home_ou actor.usr.home_ou%type;
945         new_profile actor.usr.profile%type;
946         new_home_ou actor.usr.home_ou%type;
947         new_name    text;
948         new_dob     actor.usr.dob%type;
949 BEGIN
950         SELECT
951                 id || '-PURGED-' || now(),
952                 profile,
953                 home_ou,
954                 dob
955         INTO
956                 new_name,
957                 old_profile,
958                 old_home_ou,
959                 new_dob
960         FROM
961                 actor.usr
962         WHERE
963                 id = src_usr;
964         --
965         -- Quit if no such user
966         --
967         IF old_profile IS NULL THEN
968                 RETURN;
969         END IF;
970         --
971         perform actor.usr_purge_data( src_usr, dest_usr );
972         --
973         -- Find the root grp_tree and the root org_unit.  This would be simpler if we 
974         -- could assume that there is only one root.  Theoretically, someday, maybe,
975         -- there could be multiple roots, so we take extra trouble to get the right ones.
976         --
977         SELECT
978                 id
979         INTO
980                 new_profile
981         FROM
982                 permission.grp_ancestors( old_profile )
983         WHERE
984                 parent is null;
985         --
986         SELECT
987                 id
988         INTO
989                 new_home_ou
990         FROM
991                 actor.org_unit_ancestors( old_home_ou )
992         WHERE
993                 parent_ou is null;
994         --
995         -- Truncate date of birth
996         --
997         IF new_dob IS NOT NULL THEN
998                 new_dob := date_trunc( 'year', new_dob );
999         END IF;
1000         --
1001         UPDATE
1002                 actor.usr
1003                 SET
1004                         card = NULL,
1005                         profile = new_profile,
1006                         usrname = new_name,
1007                         email = NULL,
1008                         passwd = random()::text,
1009                         standing = DEFAULT,
1010                         ident_type = 
1011                         (
1012                                 SELECT MIN( id )
1013                                 FROM config.identification_type
1014                         ),
1015                         ident_value = NULL,
1016                         ident_type2 = NULL,
1017                         ident_value2 = NULL,
1018                         net_access_level = DEFAULT,
1019                         photo_url = NULL,
1020                         prefix = NULL,
1021                         first_given_name = new_name,
1022                         second_given_name = NULL,
1023                         family_name = new_name,
1024                         suffix = NULL,
1025                         alias = NULL,
1026             guardian = NULL,
1027                         day_phone = NULL,
1028                         evening_phone = NULL,
1029                         other_phone = NULL,
1030                         mailing_address = NULL,
1031                         billing_address = NULL,
1032                         home_ou = new_home_ou,
1033                         dob = new_dob,
1034                         active = FALSE,
1035                         master_account = DEFAULT, 
1036                         super_user = DEFAULT,
1037                         barred = FALSE,
1038                         deleted = TRUE,
1039                         juvenile = DEFAULT,
1040                         usrgroup = 0,
1041                         claims_returned_count = DEFAULT,
1042                         credit_forward_balance = DEFAULT,
1043                         last_xact_id = DEFAULT,
1044                         alert_message = NULL,
1045                         create_date = now(),
1046                         expire_date = now()
1047         WHERE
1048                 id = src_usr;
1049 END;
1050 $$ LANGUAGE plpgsql;
1051
1052
1053 SELECT evergreen.upgrade_deps_block_check('1150', :eg_version);
1054
1055 INSERT INTO config.workstation_setting_type (name, grp, datatype, label)
1056 VALUES (
1057     'eg.grid.cat.vandelay.queue.bib', 'gui', 'object',
1058     oils_i18n_gettext(
1059         'eg.grid.cat.vandelay.queue.bib',
1060         'Grid Config: Vandelay Bib Queue',
1061         'cwst', 'label'
1062     )
1063 ), (
1064     'eg.grid.cat.vandelay.queue.authority', 'gui', 'object',
1065     oils_i18n_gettext(
1066         'eg.grid.cat.vandelay.queue.authority',
1067         'Grid Config: Vandelay Authority Queue',
1068         'cwst', 'label'
1069     )
1070 ), (
1071     'eg.grid.cat.vandelay.match_set.list', 'gui', 'object',
1072     oils_i18n_gettext(
1073         'eg.grid.cat.vandelay.match_set.list',
1074         'Grid Config: Vandelay Match Sets',
1075         'cwst', 'label'
1076     )
1077 ), (
1078     'eg.grid.cat.vandelay.match_set.quality', 'gui', 'object',
1079     oils_i18n_gettext(
1080         'eg.grid.cat.vandelay.match_set.quality',
1081         'Grid Config: Vandelay Match Quality Metrics',
1082         'cwst', 'label'
1083     )
1084 ), (
1085     'eg.grid.cat.vandelay.queue.items', 'gui', 'object',
1086     oils_i18n_gettext(
1087         'eg.grid.cat.vandelay.queue.items',
1088         'Grid Config: Vandelay Queue Import Items',
1089         'cwst', 'label'
1090     )
1091 ), (
1092     'eg.grid.cat.vandelay.queue.list.bib', 'gui', 'object',
1093     oils_i18n_gettext(
1094         'eg.grid.cat.vandelay.queue.list.bib',
1095         'Grid Config: Vandelay Bib Queue List',
1096         'cwst', 'label'
1097     )
1098 ), (
1099     'eg.grid.cat.vandelay.queue.bib.items', 'gui', 'object',
1100     oils_i18n_gettext(
1101         'eg.grid.cat.vandelay.queue.bib.items',
1102         'Grid Config: Vandelay Bib Items',
1103         'cwst', 'label'
1104     )
1105 ), (
1106     'eg.grid.cat.vandelay.queue.list.auth', 'gui', 'object',
1107     oils_i18n_gettext(
1108         'eg.grid.cat.vandelay.queue.list.auth',
1109         'Grid Config: Vandelay Authority Queue List',
1110         'cwst', 'label'
1111     )
1112 ), (
1113     'eg.grid.admin.vandelay.merge_profile', 'gui', 'object',
1114     oils_i18n_gettext(
1115         'eg.grid.admin.vandelay.merge_profile',
1116         'Grid Config: Vandelay Merge Profiles',
1117         'cwst', 'label'
1118     )
1119 ), (
1120     'eg.grid.admin.vandelay.bib_attr_definition', 'gui', 'object',
1121     oils_i18n_gettext(
1122         'eg.grid.admin.vandelay.bib_attr_definition',
1123         'Grid Config: Vandelay Bib Record Attributes',
1124         'cwst', 'label'
1125     )
1126 ), (
1127     'eg.grid.admin.vandelay.import_item_attr_definition', 'gui', 'object',
1128     oils_i18n_gettext(
1129         'eg.grid.admin.vandelay.import_item_attr_definition',
1130         'Grid Config: Vandelay Import Item Attributes',
1131         'cwst', 'label'
1132     )
1133 );
1134
1135
1136
1137
1138
1139 SELECT evergreen.upgrade_deps_block_check('1151', :eg_version);
1140
1141 INSERT INTO config.workstation_setting_type (name, grp, datatype, label)
1142 VALUES (
1143     'eg.cat.vandelay.import.templates', 'cat', 'object',
1144     oils_i18n_gettext(
1145         'eg.cat.vandelay.import.templates',
1146         'Vandelay Import Form Templates',
1147         'cwst', 'label'
1148     )
1149 );
1150
1151
1152 SELECT evergreen.upgrade_deps_block_check('1152', :eg_version);
1153
1154 INSERT into config.org_unit_setting_type 
1155     (name, datatype, grp, label, description)
1156 VALUES ( 
1157     'ui.staff.angular_catalog.enabled', 'bool', 'gui',
1158     oils_i18n_gettext(
1159         'ui.staff.angular_catalog.enabled',
1160         'GUI: Enable Experimental Angular Staff Catalog',
1161         'coust', 'label'
1162     ),
1163     oils_i18n_gettext(
1164         'ui.staff.angular_catalog.enabled',
1165         'Display an entry point in the browser client for the ' ||
1166         'experimental Angular staff catalog.',
1167         'coust', 'description'
1168     )
1169 );
1170
1171
1172
1173 SELECT evergreen.upgrade_deps_block_check('1153', :eg_version);
1174
1175 UPDATE config.org_unit_setting_type
1176 SET label = oils_i18n_gettext(
1177          'webstaff.cat.label.left_label.left_margin'
1178         ,'Item Print Label - Left Margin for Spine Label'
1179         ,'coust'
1180         ,'label'
1181     ),
1182      description = oils_i18n_gettext(
1183          'webstaff.cat.label.left_label.left_margin'
1184         ,'Set the default left margin for the item print Spine Label. Please include a unit of measurement that is valid CSS. For example, "1in" or "2.5cm"'
1185         ,'coust'
1186         ,'description'
1187     )
1188 WHERE NAME = 'webstaff.cat.label.left_label.left_margin';
1189
1190 UPDATE config.org_unit_setting_type
1191 SET label = oils_i18n_gettext(
1192          'webstaff.cat.label.right_label.left_margin'
1193         ,'Item Print Label - Left Margin for Pocket Label'
1194         ,'coust'
1195         ,'label'
1196     ),
1197      description = oils_i18n_gettext(
1198          'webstaff.cat.label.right_label.left_margin'
1199         ,'Set the default left margin for the item print Pocket Label (or in other words, the desired space between the two labels). Please include a unit of measurement that is valid CSS. For example, "1in" or "2.5cm"'
1200         ,'coust'
1201         ,'description'
1202     )
1203 WHERE NAME = 'webstaff.cat.label.right_label.left_margin';
1204
1205
1206 UPDATE config.org_unit_setting_type
1207 SET label = oils_i18n_gettext(
1208          'webstaff.cat.label.left_label.height'
1209         ,'Item Print Label - Height for Spine Label'
1210         ,'coust'
1211         ,'label'
1212     ),
1213      description = oils_i18n_gettext(
1214          'webstaff.cat.label.left_label.height'
1215         ,'Set the default height for the item print Spine Label. Please include a unit of measurement that is valid CSS. For example, "1in" or "2.5cm"'
1216         ,'coust'
1217         ,'description'
1218     )
1219 WHERE NAME = 'webstaff.cat.label.left_label.height';
1220
1221 UPDATE config.org_unit_setting_type
1222 SET label = oils_i18n_gettext(
1223          'webstaff.cat.label.left_label.width'
1224         ,'Item Print Label - Width for Spine Label'
1225         ,'coust'
1226         ,'label'
1227     ),
1228      description = oils_i18n_gettext(
1229          'webstaff.cat.label.left_label.width'
1230         ,'Set the default width for the item print Spine Label. Please include a unit of measurement that is valid CSS. For example, "1in" or "2.5cm"'
1231         ,'coust'
1232         ,'description'
1233     )
1234 WHERE NAME = 'webstaff.cat.label.left_label.width';
1235
1236 UPDATE config.org_unit_setting_type
1237 SET label = oils_i18n_gettext(
1238          'webstaff.cat.label.right_label.height'
1239         ,'Item Print Label - Height for Pocket Label'
1240         ,'coust'
1241         ,'label'
1242     ),
1243      description = oils_i18n_gettext(
1244          'webstaff.cat.label.right_label.height'
1245         ,'Set the default height for the item print Pocket Label. Please include a unit of measurement that is valid CSS. For example, "1in" or "2.5cm"'
1246         ,'coust'
1247         ,'description'
1248     )
1249 WHERE NAME = 'webstaff.cat.label.right_label.height';
1250
1251 UPDATE config.org_unit_setting_type
1252 SET label = oils_i18n_gettext(
1253          'webstaff.cat.label.right_label.width'
1254         ,'Item Print Label - Width for Pocket Label'
1255         ,'coust'
1256         ,'label'
1257     ),
1258      description = oils_i18n_gettext(
1259          'webstaff.cat.label.right_label.width'
1260         ,'Set the default width for the item print Pocket Label. Please include a unit of measurement that is valid CSS. For example, "1in" or "2.5cm"'
1261         ,'coust'
1262         ,'description'
1263     )
1264 WHERE NAME = 'webstaff.cat.label.right_label.width';
1265
1266
1267 SELECT evergreen.upgrade_deps_block_check('1155', :eg_version);
1268
1269 CREATE OR REPLACE FUNCTION reporter.enable_materialized_simple_record_trigger () RETURNS VOID AS $$
1270
1271     TRUNCATE TABLE reporter.materialized_simple_record;
1272
1273     INSERT INTO reporter.materialized_simple_record
1274         (id,fingerprint,quality,tcn_source,tcn_value,title,author,publisher,pubdate,isbn,issn)
1275         SELECT DISTINCT ON (id) * FROM reporter.old_super_simple_record;
1276
1277     CREATE TRIGGER bbb_simple_rec_trigger
1278         AFTER INSERT OR UPDATE OR DELETE ON biblio.record_entry
1279         FOR EACH ROW EXECUTE PROCEDURE reporter.simple_rec_trigger();
1280
1281 $$ LANGUAGE SQL;
1282
1283
1284
1285 SELECT evergreen.upgrade_deps_block_check('1156', :eg_version);
1286
1287 ALTER TABLE reporter.template ALTER COLUMN description SET DEFAULT '';
1288
1289
1290 SELECT evergreen.upgrade_deps_block_check('1159', :eg_version);
1291
1292 INSERT INTO config.marc_field(marc_format, marc_record_type, tag, name, description,
1293                               fixed_field, repeatable, mandatory, hidden)
1294 VALUES (1, 'biblio', '758', $$Resource Identifier$$, $$An identifier for a resource that is either the resource described in the bibliographic record or a resource to which it is related. Resources thus identified may include, but are not limited to, FRBR works, expressions, manifestations, and items. The field does not prescribe a particular content standard or data model.$$,
1295 FALSE, TRUE, FALSE, FALSE);
1296 INSERT INTO config.record_attr_definition(name, label)
1297 VALUES ('marc21_biblio_758_ind_1', 'MARC 21 biblio field 758 indicator position 1');
1298 INSERT INTO config.coded_value_map(ctype, code, value, opac_visible, is_simple)
1299 VALUES ('marc21_biblio_758_ind_1', '#', $$Undefined$$, FALSE, TRUE);
1300 INSERT INTO config.record_attr_definition(name, label)
1301 VALUES ('marc21_biblio_758_ind_2', 'MARC 21 biblio field 758 indicator position 2');
1302 INSERT INTO config.coded_value_map(ctype, code, value, opac_visible, is_simple)
1303 VALUES ('marc21_biblio_758_ind_2', '#', $$Undefined$$, FALSE, TRUE);
1304 INSERT INTO config.marc_subfield(marc_format, marc_record_type, tag, code, description,
1305                                  repeatable, mandatory, hidden)
1306 VALUES (1, 'biblio', '758', 'a', $$Label$$,
1307 FALSE, FALSE, FALSE);
1308 INSERT INTO config.marc_subfield(marc_format, marc_record_type, tag, code, description,
1309                                  repeatable, mandatory, hidden)
1310 VALUES (1, 'biblio', '758', 'i', $$Relationship information$$,
1311 TRUE, FALSE, FALSE);
1312 INSERT INTO config.marc_subfield(marc_format, marc_record_type, tag, code, description,
1313                                  repeatable, mandatory, hidden)
1314 VALUES (1, 'biblio', '758', '0', $$Authority record control number or standard number$$,
1315 TRUE, FALSE, FALSE);
1316 INSERT INTO config.marc_subfield(marc_format, marc_record_type, tag, code, description,
1317                                  repeatable, mandatory, hidden)
1318 VALUES (1, 'biblio', '758', '1', $$Real World Object URI$$,
1319 TRUE, FALSE, FALSE);
1320 INSERT INTO config.marc_subfield(marc_format, marc_record_type, tag, code, description,
1321                                  repeatable, mandatory, hidden)
1322 VALUES (1, 'biblio', '758', '3', $$Materials specified$$,
1323 FALSE, FALSE, FALSE);
1324 INSERT INTO config.marc_subfield(marc_format, marc_record_type, tag, code, description,
1325                                  repeatable, mandatory, hidden)
1326 VALUES (1, 'biblio', '758', '4', $$Relationship$$,
1327 TRUE, FALSE, FALSE);
1328 INSERT INTO config.marc_subfield(marc_format, marc_record_type, tag, code, description,
1329                                  repeatable, mandatory, hidden)
1330 VALUES (1, 'biblio', '758', '5', $$Institution to which field applies$$,
1331 FALSE, FALSE, FALSE);
1332 INSERT INTO config.marc_subfield(marc_format, marc_record_type, tag, code, description,
1333                                  repeatable, mandatory, hidden)
1334 VALUES (1, 'biblio', '758', '6', $$Linkage$$,
1335 FALSE, FALSE, FALSE);
1336 INSERT INTO config.marc_subfield(marc_format, marc_record_type, tag, code, description,
1337                                  repeatable, mandatory, hidden)
1338 VALUES (1, 'biblio', '758', '8', $$Field link and sequence number$$,
1339 TRUE, FALSE, FALSE);
1340
1341 COMMIT;