Update migrating patrons add a few missing steps and fix some types.
authorrsoulliere <robert.soulliere@mohawkcollege.ca>
Tue, 12 Apr 2011 13:54:19 +0000 (09:54 -0400)
committerrsoulliere <robert.soulliere@mohawkcollege.ca>
Tue, 12 Apr 2011 13:54:19 +0000 (09:54 -0400)
1.6/admin/migratingdata_1.6.xml
2.0/admin/migratingdata_2.0.xml

index 94a8132..26b96bb 100644 (file)
@@ -483,8 +483,20 @@ CREATE TABLE students (
        net_access_level int DEFAULT 2, password text\r
 ); \r
 </programlisting>\r
-                               <para>Note the <varname>DEFAULT</varname> variables. These allow you to set default for your library or to populate required fields if you data allows \r
-                               <systemitem>NULL</systemitem> values where fields are required in Evergreen.</para>\r
+                               <para>Note the <varname>DEFAULT</varname> variables. These allow you to set default for your library or to populate required fields \r
+                               if you data allows <systemitem>NULL</systemitem> values where fields are required in Evergreen.</para>\r
+                               <para>The data field <database class="field">profile</database> in the above SQL script refers to the user group and should be an\r
+                               integer referencing the <database class="field">id</database> field in <link linkend="permission.table.grp-tree">\r
+                               <database class="table">permission.grp_tree</database></link>. \r
+                               Setting this value will effect the permissions for the user. See the values in <database class="table">permission.grp_tree</database> for \r
+                               possibilities.</para> \r
+                               <para> <database class="field">ident_type</database> is the identification type used for identiying users. This is a integer value referencing \r
+                               <database class="table">config.identification_type</database> and should \r
+                               match the id values of that table. The default values are <literal>1</literal> for Drivers License, <literal>2</literal>for SSN or \r
+                               <literal>3</literal>for other.</para>\r
+                               <para><database class="field">home_ou</database> is the home organizational unit for the user. This value needs to match the corresponding \r
+                               <database class="field">id</database> in the <link linkend="actor.table.org-unit"><database class="table">actor.org_unit</database></link> \r
+                               table.</para>           \r
                        </step>\r
                        <step>\r
                                <para>Formatting of some fields to fit Evergreen filed formatting may be required. Here is an example of sql to adjust phone numbers in the staging \r
@@ -507,6 +519,17 @@ substring(phone from 10), '(', ''), ')', ''), ' ', '-');
 </programlisting>                      \r
                        </step>\r
                        <step>\r
+                               <para>Copy records into staging table from a comma delimited file.</para>\r
+<programlisting language="sql">\r
+COPY students (student_id, last_name, first_name, email, address_type, street1, street2, city, province, country, postal_code, phone) \r
+       FROM '/home/opensrf/patrons.csv' \r
+               WITH CSV HEADER;  \r
+</programlisting>\r
+                               <para>The above script wil vary depending on the format of your patron load file (<filename>patrons.csv</filename>). You may want to review \r
+                               <link xl:href="http://www.postgresql.org/docs/9.0/static/sql-copy.html" xl:title="PostgreSQL - COPY">PostgreSQL documentation</link>.</para>  \r
+                       </step>\r
+\r
+                       <step>\r
                                <para>insert records into <link linkend="actor.table.card">actor.card</link> from <link linkend="actor.table.usr">actor.usr</link>.</para>\r
 <programlisting language="sql">\r
 INSERT INTO actor.card (usr, barcode) \r
@@ -515,7 +538,8 @@ INSERT INTO actor.card (usr, barcode)
                INNER JOIN actor.usr \r
                        ON students.usrname = actor.usr.usrname;\r
 </programlisting>              \r
-                               <para>This assumes a one to one card patron relationship. If your patron data import has multiple cards assigned to one patron more complex import scripts may be required                                      which look for inactive or active flags.</para> \r
+                               <para>This assumes a one to one card patron relationship. If your patron data import has multiple cards assigned to one patron more \r
+                               complex import scripts may be required which look for inactive or active flags.</para>  \r
                        </step>\r
                        <step>\r
                                <para>Update actor.usr.card field with actor.card.id to associate active card with the user:</para>\r
@@ -571,7 +595,12 @@ CREATE TABLE students (
 ); \r
 \r
 \r
---Insert records from the staging table into the actor.usr table.\r
+--Copy records from your import text file\r
+COPY students (student_id, last_name, first_name, email, address_type, street1, street2, city, province, country, postal_code, phone) \r
+       FROM '/home/opensrf/patrons.csv' \r
+               WITH CSV HEADER;  \r
+\r
+--Insert records from the staging table into the actor.usr table\r
 INSERT INTO actor.usr (\r
        profile, usrname, email, passwd, ident_type, ident_value, first_given_name, family_name, \r
        day_phone, home_ou, claims_returned_count, net_access_level) \r
index 40e9324..2fd41c2 100644 (file)
@@ -469,17 +469,38 @@ SELECT  DISTINCT ou.id AS circ_lib,
                        <step>\r
                                <para>Create a staging table.<indexterm><primary>staging table</primary></indexterm>  A staging table will allow you to tweak the data before importing. \r
                                Here is an example sql statement:</para>\r
-                               <indexterm><primary>sql</primary></indexterm> \r
+<indexterm><primary>sql</primary></indexterm> \r
 <programlisting language="sql">\r
 CREATE TABLE students (\r
         student_id int, barcode text, last_name text, first_name text, email text, address_type text, street1 text, street2 text, \r
-       city text, province text, country text, postal_code text, phone text, profile int, \r
+       city text, province text, country text, postal_code text, phone text, profile int DEFAULT 2, \r
        ident_type int, home_ou int, claims_returned_count int DEFAULT 0, usrname text, \r
        net_access_level int DEFAULT 2, password text\r
 ); \r
 </programlisting>\r
-                               <para>Note the <varname>DEFAULT</varname> variables. These allow you to set default for your library or to populate required fields if you data allows \r
-                               <systemitem>NULL</systemitem> values where fields are required in Evergreen.</para>\r
+                               <para>Note the <varname>DEFAULT</varname> variables. These allow you to set default for your library or to populate required fields if you \r
+                               data allows <systemitem>NULL</systemitem> values where fields are required in Evergreen.</para>\r
+                               <para>The data field <database class="field">profile</database> in the above SQL script refers to the user group and should be an\r
+                               integer referencing the <database class="field">id</database> field in <link linkend="permission.table.grp-tree">\r
+                               <database class="table">permission.grp_tree</database></link>. \r
+                               Setting this value will effect the permissions for the user. See the values in <database class="table">permission.grp_tree</database> for \r
+                               possibilities.</para> \r
+                               <para> <database class="field">ident_type</database> is the identification type used for identiying users. This is a integer value referencing \r
+                               <database class="table">config.identification_type</database> and should match the id values of that table. The default values are \r
+                               <literal>1</literal> for Drivers License, <literal>2</literal>for SSN or <literal>3</literal>for other.</para>\r
+                               <para><database class="field">home_ou</database> is the home organizational unit for the user. This value needs to match the corresponding \r
+                               <database class="field">id</database> in the <link linkend="actor.table.org-unit"><database class="table">actor.org_unit</database></link> \r
+                               table.</para>    \r
+                       </step>\r
+                       <step>\r
+                               <para>Copy records into staging table from a comma delimited file.</para>\r
+<programlisting language="sql">\r
+COPY students (student_id, last_name, first_name, email, address_type, street1, street2, city, province, country, postal_code, phone) \r
+       FROM '/home/opensrf/patrons.csv' \r
+               WITH CSV HEADER;  \r
+</programlisting>\r
+                               <para>The above script wil vary depending on the format of your patron load file (<filename>patrons.csv</filename>). You may want to review \r
+                               <link xl:href="http://www.postgresql.org/docs/9.0/static/sql-copy.html" xl:title="PostgreSQL - COPY">PostgreSQL documentation</link></para>  \r
                        </step>\r
                        <step>\r
                                <para>Formatting of some fields to fit Evergreen filed formatting may be required. Here is an example of sql to adjust phone numbers in the staging \r
@@ -488,10 +509,10 @@ CREATE TABLE students (
 UPDATE students phone = replace(replace(replace(rpad(substring(phone from 1 for 9), 10, '-') || \r
 substring(phone from 10), '(', ''), ')', ''), ' ', '-');\r
 </programlisting>\r
-                               <para>Data <quote>massaging</quote> may be required to fit formats used in Evergreen.</para>\r
+                               <para>Data <quote>massaging</quote> will be required to fit formats used in Evergreen.</para>\r
                        </step>\r
                        <step>\r
-                               <para>Insert records from the staging table into the <link linkend="actor.table.usr">actor.usr</link> Evergreen table:</para>\r
+                               <para>Insert records from the staging table into the <link linkend="actor.table.usr"><database class="table">actor.usr</database> </link> Evergreen table:</para>\r
 <programlisting language="sql">\r
  INSERT INTO actor.usr (\r
        profile, usrname, email, passwd, ident_type, ident_value, first_given_name, \r
@@ -499,10 +520,11 @@ substring(phone from 10), '(', ''), ')', ''), ' ', '-');
        SELECT profile, students.usrname, email, student_id, ident_type, student_id, \r
        first_name, last_name, phone, home_ou, claims_returned_count, net_access_level \r
        FROM students;\r
-</programlisting>                      \r
+</programlisting>              \r
                        </step>\r
                        <step>\r
-                               <para>insert records into <link linkend="actor.table.card">actor.card</link> from <link linkend="actor.table.usr">actor.usr</link>.</para>\r
+                               <para>insert records into <link linkend="actor.table.card"><database class="table">actor.card </database></link> from <link linkend="actor.table.usr">\r
+                               <database class="table">actor.usr </database></link>.</para>\r
 <programlisting language="sql">\r
 INSERT INTO actor.card (usr, barcode) \r
        SELECT actor.usr.id, students.barcode \r
@@ -565,6 +587,11 @@ CREATE TABLE students (
        net_access_level int DEFAULT 2, password text\r
 ); \r
 \r
+--Copy records from your import text file\r
+COPY students (student_id, last_name, first_name, email, address_type, street1, street2, city, province, country, postal_code, phone) \r
+       FROM '/home/opensrf/patrons.csv' \r
+               WITH CSV HEADER;  \r
+\r
 \r
 --Insert records from the staging table into the actor.usr table.\r
 INSERT INTO actor.usr (\r