thesaurus upgrade script fixes
authorGalen Charlton <gmc@equinoxinitiative.org>
Thu, 27 Jul 2017 20:21:29 +0000 (20:21 +0000)
committerGalen Charlton <gmc@equinoxinitiative.org>
Thu, 27 Jul 2017 20:21:29 +0000 (20:21 +0000)
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/sql/Pg/upgrade/YYYY.schema.thesauri.sql

index 84566cb..53a9133 100644 (file)
@@ -1,10 +1,10 @@
 BEGIN;
 
-CREATE TRIGGER thes_code_tracking_trigger
-    AFTER UPDATE ON authority.thesaurus
-    FOR EACH ROW EXECUTE PROCEDURE oils_i18n_code_tracking('at');
+--CREATE TRIGGER thes_code_tracking_trigger
+    --AFTER UPDATE ON authority.thesaurus
+    --FOR EACH ROW EXECUTE PROCEDURE oils_i18n_code_tracking('at');
 
-ALTER TABLE authority.thesaurus ADD COLUMN short_code TEXT, uri TEXT;
+--ALTER TABLE authority.thesaurus ADD COLUMN short_code TEXT, uri TEXT;
 
 DELETE FROM authority.thesaurus WHERE control_set = 1 AND code NOT IN ('n',' ','|');
 UPDATE authority.thesaurus SET short_code = code;
@@ -216,7 +216,6 @@ ccsa        http://id.loc.gov/vocabulary/subjectSchemes/ccsa        Catalogue collectif suisse
 noraf  http://id.loc.gov/vocabulary/subjectSchemes/noraf       Norwegian Authority File        
 kito   http://id.loc.gov/vocabulary/subjectSchemes/kito        KITO - Kirjallisuudentutkimuksen ontologia      "fi"=>"KITO - Kirjallisuudentutkimuksen ontologia"
 tho    http://id.loc.gov/vocabulary/subjectSchemes/tho Thesauros HellÄ\93nikÅ\8dn Oron "el"=>"Thesauros HellÄ\93nikÅ\8dn Oron"
-ept    http://id.loc.gov/vocabulary/subjectSchemes/ept European education thesaurus    "sl"=>"Evropski pedagoÅ¡ki tezaver"
 pmont  http://id.loc.gov/vocabulary/subjectSchemes/pmont       Powerhouse Museum Object Name Thesaurus 
 ssg    http://id.loc.gov/vocabulary/subjectSchemes/ssg SploÅ¡ni slovenski geslovnik  "sl"=>"SploÅ¡ni slovenski geslovnik"
 huc    http://id.loc.gov/vocabulary/subjectSchemes/huc U.S. Geological Survey water-supply paper 2294: hydrologic basins unit codes    
@@ -244,7 +243,6 @@ snt http://id.loc.gov/vocabulary/subjectSchemes/snt Sexual nomenclature : a thes
 francis        http://id.loc.gov/vocabulary/subjectSchemes/francis     FRANCIS database classification scheme  "fr"=>"Base de donneés FRANCIS: plan de classement"
 eurovocsl      http://id.loc.gov/vocabulary/subjectSchemes/eurovocsl   Eurovoc thesaurus       "sl"=>"Eurovoc thesaurus"
 idszbzes       http://id.loc.gov/vocabulary/subjectSchemes/idszbzes    Thesaurus IDS Nebis Bibliothek Englisches Seminar der Universität Zürich  "de"=>"Thesaurus IDS Nebis Bibliothek Englisches Seminar der Universität Zürich"
-gnd    http://id.loc.gov/vocabulary/subjectSchemes/gnd Gemeinsame Normdatei    "de"=>"Gemeinsame Normdatei"
 nlmnaf http://id.loc.gov/vocabulary/subjectSchemes/nlmnaf      National Library of Medicine name authority file        
 rugeo  http://id.loc.gov/vocabulary/subjectSchemes/rugeo       Natsional'nyi normativnyi fail geograficheskikh nazvanii Rossiiskoi Federatsii  "ru"=>"Natsional'nyi normativnyi fail geograficheskikh nazvanii Rossiiskoi Federatsii"
 sipri  http://id.loc.gov/vocabulary/subjectSchemes/sipri       SIPRI library thesaurus 
@@ -411,7 +409,7 @@ csht        http://id.loc.gov/vocabulary/subjectSchemes/csht        Chinese subject headings
 -- ' ...blah
 
 INSERT INTO authority.thesaurus (code, uri, name, control_set)
-  SELECT code, uri, name, 1 FROM thesausi;
+  SELECT code, uri, name, 1 FROM thesauri;
 
 UPDATE authority.thesaurus SET short_code = 'a' WHERE code = 'lcsh';
 UPDATE authority.thesaurus SET short_code = 'b' WHERE code = 'lcshac';
@@ -428,17 +426,17 @@ UPDATE  authority.thesaurus
         AND control_set = 1;
 
 INSERT INTO config.i18n_core (fq_field, identity_value, translation, string )
-  SELECT  'at.name', t.code, (xlate).key, (xlate).value
-    FROM  thesauri t,
+  SELECT  'at.name', t.code, xlate->key, xlate->value
+    FROM  thesauri t
           JOIN LATERAL each(t.xlate) AS xlate ON TRUE
     WHERE NOT EXISTS
             (SELECT id
               FROM  config.i18n_core
               WHERE fq_field = 'at.name'
                     AND identity_value = t.code
-                    AND translation = each.key)
+                    AND translation = xlate->key)
           AND t.xlate IS NOT NULL
-          AND t.name <> each.value;
+          AND t.name <> (xlate->value);
 
 CREATE OR REPLACE FUNCTION authority.extract_thesaurus( marcxml TEXT ) RETURNS TEXT AS $func$
 DECLARE