From b01017d23bea803c717fa77270d02ff351aa80fd Mon Sep 17 00:00:00 2001 From: rsoulliere Date: Mon, 18 Apr 2011 09:50:31 -0400 Subject: [PATCH] Fix sql error found by Demian Katz. --- 1.6/admin/migratingdata_1.6.xml | 20 +++++++++++++++++--- 2.0/admin/migratingdata_2.0.xml | 6 +++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/1.6/admin/migratingdata_1.6.xml b/1.6/admin/migratingdata_1.6.xml index 4558d06066..00c4d61548 100644 --- a/1.6/admin/migratingdata_1.6.xml +++ b/1.6/admin/migratingdata_1.6.xml @@ -498,6 +498,16 @@ CREATE TABLE students ( id in the actor.org_unit table. + + Copy records into staging table from a comma delimited file. + +COPY students (student_id, last_name, first_name, email, address_type, street1, street2, city, province, country, postal_code, phone, password) + FROM '/home/opensrf/patrons.csv' + WITH CSV HEADER; + + The above script wil vary depending on the format of your patron load file (patrons.csv). You may want to review + PostgreSQL documentation + 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 table to fit the evergreen field: @@ -507,13 +517,17 @@ substring(phone from 10), '(', ''), ')', ''), ' ', '-'); Data massaging may be required to fit formats used in Evergreen. + + + + Insert records from the staging table into the actor.usr Evergreen table: INSERT INTO actor.usr ( profile, usrname, email, passwd, ident_type, ident_value, first_given_name, family_name, day_phone, home_ou, claims_returned_count, net_access_level) - SELECT profile, students.usrname, email, student_id, ident_type, student_id, + SELECT profile, students.usrname, email, password, ident_type, student_id, first_name, last_name, phone, home_ou, claims_returned_count, net_access_level FROM students; @@ -596,7 +610,7 @@ CREATE TABLE students ( --Copy records from your import text file -COPY students (student_id, last_name, first_name, email, address_type, street1, street2, city, province, country, postal_code, phone) +COPY students (student_id, last_name, first_name, email, address_type, street1, street2, city, province, country, postal_code, phone, password) FROM '/home/opensrf/patrons.csv' WITH CSV HEADER; @@ -604,7 +618,7 @@ COPY students (student_id, last_name, first_name, email, address_type, street1, INSERT INTO actor.usr ( profile, usrname, email, passwd, ident_type, ident_value, first_given_name, family_name, day_phone, home_ou, claims_returned_count, net_access_level) - SELECT profile, students.usrname, email, student_id, ident_type, student_id, first_name, + SELECT profile, students.usrname, email, password, ident_type, student_id, first_name, last_name, phone, home_ou, claims_returned_count, net_access_level FROM students; --Insert records from the staging table into the actor.usr table. diff --git a/2.0/admin/migratingdata_2.0.xml b/2.0/admin/migratingdata_2.0.xml index 3b4c5a6464..6f5f5ab9eb 100644 --- a/2.0/admin/migratingdata_2.0.xml +++ b/2.0/admin/migratingdata_2.0.xml @@ -517,7 +517,7 @@ substring(phone from 10), '(', ''), ')', ''), ' ', '-'); INSERT INTO actor.usr ( profile, usrname, email, passwd, ident_type, ident_value, first_given_name, family_name, day_phone, home_ou, claims_returned_count, net_access_level) - SELECT profile, students.usrname, email, student_id, ident_type, student_id, + SELECT profile, students.usrname, email, password, ident_type, student_id, first_name, last_name, phone, home_ou, claims_returned_count, net_access_level FROM students; @@ -588,7 +588,7 @@ CREATE TABLE students ( ); --Copy records from your import text file -COPY students (student_id, last_name, first_name, email, address_type, street1, street2, city, province, country, postal_code, phone) +COPY students (student_id, last_name, first_name, email, address_type, street1, street2, city, province, country, postal_code, phone, password) FROM '/home/opensrf/patrons.csv' WITH CSV HEADER; @@ -597,7 +597,7 @@ COPY students (student_id, last_name, first_name, email, address_type, street1, INSERT INTO actor.usr ( profile, usrname, email, passwd, ident_type, ident_value, first_given_name, family_name, day_phone, home_ou, claims_returned_count, net_access_level) - SELECT profile, students.usrname, email, student_id, ident_type, student_id, first_name, + SELECT profile, students.usrname, email, password, ident_type, student_id, first_name, last_name, phone, home_ou, claims_returned_count, net_access_level FROM students; --Insert records from the staging table into the actor.usr table. -- 2.43.2