Fix SQL in migrating data. Bug https://bugs.launchpad.net/evergreen/+bug/720068 repor...
authorRobert Soulliere <rsoulliere@libdog.mohawkcollege.ca>
Wed, 16 Feb 2011 18:01:40 +0000 (13:01 -0500)
committerRobert Soulliere <rsoulliere@libdog.mohawkcollege.ca>
Wed, 16 Feb 2011 18:01:40 +0000 (13:01 -0500)
1.6/admin/migratingdata_1.6.xml
2.0/admin/Upgrading-Evergreen-2.0.xml
2.0/admin/migratingdata_2.0.xml

index 305f916..cb665ae 100644 (file)
@@ -308,7 +308,7 @@ extract_holdings --marcfile=clean.marc.xml --holding 999 --copyid 999i --map hol
                                <para>The <option>map</option> option <filename>holdings.map</filename> refers to a file to be used for mapping subfields to the holdings data you would like extracted. Here is an example based on mapping holdings data to the 999 data field:</para>\r
 <programlisting>\r
 <![CDATA[\r
-call_num 999 a\r
+callnum 999 a\r
 barcode 999 i\r
 location 999 l\r
 owning_lib 999 m\r
@@ -332,7 +332,7 @@ BEGIN;
 \r
 <emphasis class="bold">TRUNCATE TABLE staging_items;</emphasis>\r
 \r
-<emphasis class="bold">INSERT INTO staging_items (</emphasis>egid, hseq, l_call_num, l_barcode, \r
+<emphasis class="bold">INSERT INTO staging_items (</emphasis>egid, hseq, l_callnum, l_barcode, \r
 l_location, l_owning_lib, l_circ_modifier <emphasis>FROM stdin;</emphasis> \r
 40      0       HD3616.K853 U54 1997    30731100751928  STACKS  FENNELL BOOK\r
 41      1       HV6548.C3 S984 1998     30731100826613  STACKS  FENNELL BOOK\r
@@ -356,14 +356,14 @@ l_location, l_owning_lib, l_circ_modifier <emphasis>FROM stdin;</emphasis>
                                <para>Create a staging_items staging table to hold the holdings data:</para>\r
 <programlisting language="sql">\r
 CREATE TABLE staging_items (\r
-        callnum text, -- call number label\r
+        l_callnum text, -- call number label\r
        hseq int, -- call number label\r
         egid  int,  -- biblio.record_entry_id\r
         createdate      date,\r
-        location        text,\r
-        barcode         text,\r
-        item_type       text,\r
-        owning_lib      text  -- actor.org_unit.shortname\r
+        l_location        text,\r
+        l_barcode         text,\r
+        l_circ_modifier       text,\r
+        l_owning_lib      text  -- actor.org_unit.shortname\r
 );\r
 </programlisting>\r
                        </step> \r
@@ -380,31 +380,31 @@ CREATE TABLE staging_items (
                                <para>Generate shelving locations from your staging table.</para>\r
 <programlisting language="sql">\r
 INSERT INTO asset.copy_location (name, owning_lib)\r
-SELECT  DISTINCT l.location, ou.id\r
+SELECT  DISTINCT l.l_location, ou.id\r
 FROM  staging_items l \r
-       JOIN actor.org_unit ou  ON (l.owning_lib = ou.shortname); \r
+       JOIN actor.org_unit ou  ON (l.l_owning_lib = ou.shortname); \r
 </programlisting>\r
                        </step>\r
                        <step>\r
                                <para>Generate circulation modifiers from your staging table.</para>\r
 <programlisting language="sql">\r
 INSERT INTO config.circ_modifier (code, name, description, sip2_media_type, magnetic_media)\r
-        SELECT  DISTINCT item_type AS code,\r
-          item_type AS name,\r
-          LOWER(item_type) AS description,\r
+        SELECT  DISTINCT l_circ_modifier AS code,\r
+          l_circ_modifier AS name,\r
+          LOWER(l_circ_modifier) AS description,\r
           '001' AS sip2_media_type,\r
           FALSE AS magnetic_media\r
           FROM  staging_items\r
-          WHERE item_type NOT IN (SELECT code FROM config.circ_modifier);\r
+          WHERE l_circ_modifier NOT IN (SELECT code FROM config.circ_modifier);\r
 </programlisting>\r
                        </step>\r
                        <step>\r
                                <para>Generate call numbers from your staging table:</para>\r
 <programlisting language="sql">\r
 INSERT INTO asset.call_number (creator,editor,record,label,owning_lib)\r
-SELECT  DISTINCT 1, 1, b.id, l.callnum, ou.id\r
-FROM  staging.staging_items l\r
-JOIN actor.org_unit ou ON (l.owning_lib = ou.shortname);\r
+  SELECT  DISTINCT 1, 1, l.egid, l.l_callnum, ou.id\r
+  FROM  staging_items l\r
+  JOIN actor.org_unit ou ON (l.l_owning_lib = ou.shortname);\r
 </programlisting>\r
                        </step>\r
                        <step>\r
@@ -417,27 +417,30 @@ STATUS, location, loan_duration, fine_level, circ_modifier, deposit, ref, call_n
 SELECT  DISTINCT ou.id AS circ_lib,\r
        1 AS creator,\r
        1 AS editor,\r
-       l.createdate AS create_date,\r
-       l.barcode AS barcode,\r
+       l.l_createdate AS create_date,\r
+       l.l_barcode AS barcode,\r
        0 AS STATUS,\r
        cl.id AS location,\r
        2 AS loan_duration,\r
        2 AS fine_level,\r
-       l.item_type AS circ_modifier,\r
+       l.l_circ_modifier AS circ_modifier,\r
        FALSE AS deposit,\r
        CASE\r
-       WHEN l.item_type = 'REFERENCE' THEN TRUE\r
+       WHEN l.l_circ_modifier = 'REFERENCE' THEN TRUE\r
        ELSE FALSE\r
        END AS ref,                                             \r
        cn.id AS call_number\r
-       FROM  staging.staging_items l\r
-       JOIN actor.org_unit ou\r
-               ON (l.owning_lib = ou.shortname)\r
-       JOIN asset.copy_location cl\r
-               ON (ou.id = cl.owning_lib AND l.location = cl.name)\r
-       JOIN asset.call_number cn\r
-               ON (ou.id = cn.owning_lib      \r
-               AND l.callnum = cn.label);\r
+       FROM  staging_items l\r
+               JOIN actor.org_unit ou\r
+                       ON (l.owning_lib = ou.shortname)\r
+               JOIN asset.copy_location cl\r
+                       ON (ou.id = cl.owning_lib AND l.l_location = cl.name)\r
+               JOIN metabib.real_full_rec m \r
+                       ON (m.value = l.egid)\r
+               JOIN asset.call_number cn\r
+                       ON (ou.id = cn.owning_lib  \r
+                       AND m.record = cn.record       \r
+                       AND l.l_callnum = cn.label)      \r
 </programlisting>\r
                                <para>You should now have copies in your Evergreen database and should be able to search and find the bibliographic records with attached copies.</para> \r
                        </step>\r
index 284723e..68c9f69 100644 (file)
@@ -8,9 +8,18 @@
                        </application> to 2.0, including steps to upgrade <application>OpenSRF</application>. Before \r
                        upgrading, it is important to carefully plan an upgrade strategy to minimize system downtime and \r
                        service interruptions. All of the steps in this chapter are to be completed from the command line.</para>\r
+                       \r
                </abstract>\r
        </info>    \r
-               <para>In the following instructions, you are asked to perform certain steps as either the <systemitem class="username">root</systemitem>  or <systemitem class="username">opensrf</systemitem> user.</para>\r
+               <para>Evergreen 2.0 has several software requirements:</para>\r
+               <itemizedlist>\r
+                       <listitem>PostgreSQL: Version 8.4 is the minimum supported version of PostgreSQL. </listitem>\r
+                       <listitem>Linux: Evergreen 2.0 has been tested on Debian Squeeze (6.0) and Ubuntu Lucid Lynx (10.04). If you are runnung an older version of these distributions, \r
+                       you may want to upgrade befor installing Evergreen 2.0. For instructions om upgrading these distribuitions, visit the \r
+                       <ulink url="http://www.debian.org/releases/squeeze/">Debian</ulink> or <ulink url="https://help.ubuntu.com/community/LucidUpgrades">Ubuntu</ulink> websites.</listitem>\r
+               </itemizedlist>\r
+               <para>In the following instructions, you are asked to perform certain steps as either the <systemitem class="username">root</systemitem>  or \r
+               <systemitem class="username">opensrf</systemitem> user.</para>\r
                <itemizedlist>\r
                        <listitem>Debian: To become the <systemitem class="username">root</systemitem> user, issue the <command>su</command> command and enter the password of the \r
                        <systemitem class="username">root</systemitem> user.</listitem>\r
@@ -67,27 +76,21 @@ cd /home/opensrf/OpenSRF-1.6.2
                                <para>Replace <option>[distribution]</option> below with the following value \r
                                for your distribution:</para>\r
                                <itemizedlist>\r
-                                       \r
-                                       <listitem>\r
-                                               <para><option>debian-lenny</option> for <systemitem class="osname">Debian Lenny (5.0)</systemitem></para>\r
-                                       </listitem>\r
                                        <listitem>\r
                                                <para><option>debian-squeeze</option> for <systemitem class="osname">Debian Squeeze (6.0)</systemitem>\r
                                                <indexterm><primary>Linux</primary><secondary>Debian</secondary></indexterm></para>\r
                                        </listitem>\r
                                        <listitem>\r
-                                       <para><option>ubuntu-hardy</option> for <systemitem class="osname">Ubuntu Hardy Heron (8.04)</systemitem>\r
-                                       <indexterm><primary>Linux</primary><secondary>Ubuntu</secondary></indexterm></para>\r
-                                       </listitem>\r
-                                       <listitem>\r
                                                <para><option>ubuntu-lucid</option> for <systemitem class="osname">Ubuntu Lucid Lynx\r
-                                               (10.04)</systemitem></para>\r
+                                               (10.04)</systemitem><indexterm><primary>Linux</primary><secondary>Ubuntu</secondary></indexterm></para>\r
                                        </listitem>\r
                                        <listitem>\r
-                                               <para><option>centos</option> for <systemitem class="osname">CentOS 5</systemitem></para>\r
+                                               <para><option>centos</option> for <systemitem class="osname">CentOS 5</systemitem>\r
+                                               <indexterm><primary>Linux</primary><secondary>CentOS</secondary></indexterm></para>\r
                                        </listitem>\r
                                        <listitem>\r
-                                               <para><option>rhel</option> for <systemitem class="osname">Red Hat Enterprise Linux 5</systemitem></para>\r
+                                               <para><option>rhel</option> for <systemitem class="osname">Red Hat Enterprise Linux 5</systemitem>\r
+                                               <indexterm><primary>Linux</primary><secondary>Red Hat</secondary></indexterm></para>\r
                                        </listitem>\r
                                </itemizedlist>\r
 <screen><userinput>\r
@@ -151,13 +154,15 @@ srfsh#
        </section>\r
        <section xml:id="upgradingevergreen-upgrading_from_1.6_to_2.0">\r
                <title>Upgrade <application>Evergreen</application> from 1.6.1 to 2.0</title>\r
+               <note><para>8.4 is the minimum supported version of PostgreSQL. Evergreen 2.0 has been tested on Debian Squeeze (6.0) and Ubuntu Lucid (10.04). If you are runnung an older version of \r
+                       these distributions, you may want to upgrade befor installing Evergreen 2.0. For instructions om upgrading these distribuitions, visit the \r
+                       <ulink url="http://www.debian.org/releases/squeeze/">Debian</ulink> or <ulink url="https://help.ubuntu.com/community/LucidUpgrades">Ubuntu</ulink> websites.</para></note>\r
                <procedure>\r
                        <step>\r
                                <para>As the <systemitem class="username">opensrf</systemitem> user, download and extract <application>Evergreen 2.0</application>\r
                                </para>\r
 <screen><userinput>\r
-wget http://www.open-ils.org/downloads/exit\r
-uEvergreen-ILS-2.0.1.tar.gz\r
+wget http://www.open-ils.org/downloads/Evergreen-ILS-2.0.1.tar.gz\r
 tar xzf Evergreen-ILS-2.0.1.tar.gz\r
 </userinput></screen>\r
                                <note><para>For the latest edition of Evergreen 2.0, check the Evergreen download page at\r
@@ -204,25 +209,15 @@ tar xzf Evergreen-ILS-2.0.1.tar.gz
                                <screen><userinput>chown -R opensrf:opensrf /openils</userinput></screen>\r
                        </step>                 \r
                        <step>\r
-                               <para>As the <systemitem class="username">root</systemitem> user, build <filename>live-db-setup.pl</filename> for the cgi-bin \r
-                               bootstrapping scripts and <filename>offline-config.pl</filename> for the offline staff client data uploader:</para>\r
-<screen><userinput>\r
-cd /home/opensrf/Evergreen-ILS-2.0.1\r
-perl Open-ILS/src/support-scripts/eg_db_config.pl --create-bootstrap --create-offline \ \r
---user evergreen --password evergreen --hostname localhost --port 5432 \\r
---database evergreen\r
-</userinput></screen>\r
-                       </step>\r
-                       <step>\r
                                <para>As the <systemitem class="username">opensrf</systemitem> user, update server symlink in <filename class="directory">/openils/var/web/xul/</filename>:</para>\r
 <screen><userinput>\r
 cd /openils/var/web/xul/\r
 rm server\r
-ln -s rel_1_6_1_5/server\r
+ln -s rel_2_0_1/server\r
 </userinput></screen>\r
                        </step>\r
                        <step>\r
-                               <para>Update the Evergreen database:</para>\r
+                               <para>Update the <database>evergreen</database> database:</para>\r
                                <note><para>It is recommended that you <link linkend="backingup">back up your Evergreen database</link> in order to restore your data if anything goes wrong.</para></note>\r
 <screen>\r
 <userinput>\r
@@ -232,9 +227,9 @@ psql -U evergreen -h localhost -f Open-ILS/src/sql/Pg/2.0.0-2.0.1-upgrade-db.sql
 </screen>      \r
                        </step>\r
 <step>\r
-                               <para>Run the <filename>reingest-1.6-2.0.pl<filename> script to generate an sql script. Then use the sql file to reingest bib records into your \r
-                               <database>evergreen<batabase> database. This is required to make the new facet sidebar in OPAC search results work and to upgrade the keyword indexes to use \r
-                               the revised NACO normalization routine</para>\r
+                               <para>Run the <filename>reingest-1.6-2.0.pl</filename> script to generate an sql script. Then use the sql file to reingest bib records into your \r
+                               <database>evergreen</database> database. This is required to make the new facet sidebar in OPAC search results work and to upgrade the keyword indexes to use \r
+                               the revised NACO normalization routine.</para>\r
                                <note><para>If you are running a large Evergreen installation, it is recommend that you examine the script first. Reingesting a large number of bibliographic records \r
                                may take several hours.</para></note>\r
 <screen><userinput>perl Open-ILS/src/sql/Pg/reingest-1.6-2.0.pl</userinput></screen>\r
@@ -258,7 +253,7 @@ psql -U evergreen -h localhost -f Open-ILS/src/sql/Pg/2.0.0-2.0.1-upgrade-db.sql
                        <step>\r
                                <para>Update <filename>opensrf.xml</filename> with the database connection info:</para>\r
 <screen><userinput>\r
-perl Open-ILS/src/support-scripts/eg_db_config.pl --update-config --service all --user evergreen \\r
+perl Open-ILS/src/support-scripts/eg_db_config.pl --update-config --service all --create-offline --user evergreen \\r
 --password evergreen --hostname localhost --port 5432 --database evergreen\r
 </userinput></screen>\r
                        </step>\r
index f1121f0..8cd94c3 100644 (file)
@@ -327,7 +327,7 @@ BEGIN;
 \r
 <emphasis class="bold">TRUNCATE TABLE staging_items;</emphasis>\r
 \r
-<emphasis class="bold">INSERT INTO staging_items (</emphasis>egid, hseq, l_call_num, l_barcode, l_location, \r
+<emphasis class="bold">INSERT INTO staging_items (</emphasis>egid, hseq, l_callnum, l_barcode, l_location, \r
 l_owning_lib, l_circ_modifier <emphasis>FROM stdin;</emphasis> \r
 40      0       HD3616.K853 U54 1997    30731100751928  STACKS  FENNELL BOOK\r
 41      1       HV6548.C3 S984 1998     30731100826613  STACKS  FENNELL BOOK\r
@@ -351,14 +351,14 @@ l_owning_lib, l_circ_modifier <emphasis>FROM stdin;</emphasis>
                                <para>Create a staging_items staging table to hold the holdings data:</para>\r
 <programlisting language="sql">\r
 CREATE TABLE staging_items (\r
-        callnum text, -- call number label\r
+        l_callnum text, -- call number label\r
        hseq int, -- call number label\r
         egid  int,  -- biblio.record_entry_id\r
         createdate      date,\r
-        location        text,\r
-        barcode         text,\r
-        item_type       text,\r
-        owning_lib      text  -- actor.org_unit.shortname\r
+        l_location        text,\r
+        l_barcode         text,\r
+        l_circ_modifier   text,\r
+        l_owning_lib      text  -- actor.org_unit.shortname\r
 );\r
 </programlisting>\r
                        </step> \r
@@ -384,20 +384,20 @@ FROM  staging_items l
                                <para>Generate circulation modifiers from your staging table.</para>\r
 <programlisting language="sql">\r
 INSERT INTO config.circ_modifier (code, name, description, sip2_media_type, magnetic_media)\r
-        SELECT  DISTINCT item_type AS code,\r
-          item_type AS name,\r
-          LOWER(item_type) AS description,\r
+        SELECT  DISTINCT l_circ_modifier AS code,\r
+          l_circ_modifier AS name,\r
+          LOWER(l_circ_modifier) AS description,\r
           '001' AS sip2_media_type,\r
           FALSE AS magnetic_media\r
           FROM  staging_items\r
-          WHERE item_type NOT IN (SELECT code FROM config.circ_modifier);\r
+          WHERE l_circ_modifier NOT IN (SELECT code FROM config.circ_modifier);\r
 </programlisting>\r
                        </step>\r
                        <step>\r
                                <para>Generate call numbers from your staging table:</para>\r
 <programlisting language="sql">\r
 INSERT INTO asset.call_number (creator,editor,record,label,owning_lib)\r
-SELECT  DISTINCT 1, 1, b.id, l.callnum, ou.id\r
+SELECT  DISTINCT 1, 1, egid, l.callnum, ou.id\r
 FROM  staging.staging_items l\r
 JOIN actor.org_unit ou ON (l.owning_lib = ou.shortname);\r
 </programlisting>\r
@@ -412,27 +412,30 @@ STATUS, location, loan_duration, fine_level, circ_modifier, deposit, ref, call_n
 SELECT  DISTINCT ou.id AS circ_lib,\r
        1 AS creator,\r
        1 AS editor,\r
-       l.createdate AS create_date,\r
-       l.barcode AS barcode,\r
+       l.l_createdate AS create_date,\r
+       l.l_barcode AS barcode,\r
        0 AS STATUS,\r
        cl.id AS location,\r
        2 AS loan_duration,\r
        2 AS fine_level,\r
-       l.item_type AS circ_modifier,\r
+       l.l_circ_modifier AS circ_modifier,\r
        FALSE AS deposit,\r
        CASE\r
-       WHEN l.item_type = 'REFERENCE' THEN TRUE\r
+       WHEN l.l_circ_modifier = 'REFERENCE' THEN TRUE\r
        ELSE FALSE\r
        END AS ref,                                             \r
        cn.id AS call_number\r
-       FROM  staging.staging_items l\r
-       JOIN actor.org_unit ou\r
-               ON (l.owning_lib = ou.shortname)\r
-       JOIN asset.copy_location cl\r
-               ON (ou.id = cl.owning_lib AND l.location = cl.name)\r
-       JOIN asset.call_number cn\r
-               ON (ou.id = cn.owning_lib      \r
-               AND l.callnum = cn.label);\r
+       FROM  staging_items l\r
+               JOIN actor.org_unit ou\r
+                       ON (l.owning_lib = ou.shortname)\r
+               JOIN asset.copy_location cl\r
+                       ON (ou.id = cl.owning_lib AND l.l_location = cl.name)\r
+               JOIN metabib.real_full_rec m \r
+                       ON (m.value = l.egid)\r
+               JOIN asset.call_number cn\r
+                       ON (ou.id = cn.owning_lib  \r
+                       AND m.record = cn.record       \r
+                       AND l.l_callnum = cn.label)      \r
 </programlisting>\r
                                <para>You should now have copies in your Evergreen database and should be able to search and find the bibliographic records with attached copies.</para> \r
                        </step>\r