From: Dan Scott Date: Sun, 2 Sep 2012 02:59:21 +0000 (-0400) Subject: Do the SQL upgrade dance for list pubdate in CSV X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=69b28b8dd84974e4515c3f59f2dbbfa4595bca04;p=contrib%2FConifer.git Do the SQL upgrade dance for list pubdate in CSV With a slight tweak to base the upgrade off of the event definition name instead of the ID; possibly more resilient. Signed-off-by: Dan Scott --- diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index 1ded67eddb..8439b14644 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -87,7 +87,7 @@ CREATE TRIGGER no_overlapping_deps BEFORE INSERT OR UPDATE ON config.db_patch_dependencies FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates'); -INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0736', :eg_version); -- miker/tsbere +INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0737', :eg_version); -- dyrcona/dbs CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, diff --git a/Open-ILS/src/sql/Pg/upgrade/0737.data.update_ContainerCSV_template.sql b/Open-ILS/src/sql/Pg/upgrade/0737.data.update_ContainerCSV_template.sql new file mode 100644 index 0000000000..6e1106f3f1 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0737.data.update_ContainerCSV_template.sql @@ -0,0 +1,33 @@ +BEGIN; +-- check whether patch can be applied +SELECT evergreen.upgrade_deps_block_check('0737', :eg_version); + +UPDATE action_trigger.event_definition +SET template = +$$ +[%- +# target is the bookbag itself. The 'items' variable does not need to be in +# the environment because a special reactor will take care of filling it in. + +FOR item IN items; + bibxml = helpers.unapi_bre(item.target_biblio_record_entry, {flesh => '{mra}'}); + title = ""; + FOR part IN bibxml.findnodes('//*[@tag="245"]/*[@code="a" or @code="b"]'); + title = title _ part.textContent; + END; + author = bibxml.findnodes('//*[@tag="100"]/*[@code="a"]').textContent; + item_type = bibxml.findnodes('//*[local-name()="attributes"]/*[local-name()="field"][@name="item_type"]').getAttribute('coded-value'); + pub_date = ""; + FOR pdatum IN bibxml.findnodes('//*[@tag="260"]/*[@code="c"]'); + IF pub_date ; + pub_date = pub_date _ ", " _ pdatum.textContent; + ELSE ; + pub_date = pdatum.textContent; + END; + END; + helpers.csv_datum(title) %],[% helpers.csv_datum(author) %],[% helpers.csv_datum(pub_date) %],[% helpers.csv_datum(item_type) %],[% FOR note IN item.notes; helpers.csv_datum(note.note); ","; END; "\n"; +END -%] +$$ +WHERE name = 'Bookbag CSV'; + +COMMIT; diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.update_ContainerCSV_template.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.update_ContainerCSV_template.sql deleted file mode 100644 index 5af0feb52a..0000000000 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.update_ContainerCSV_template.sql +++ /dev/null @@ -1,33 +0,0 @@ -BEGIN; --- check whether patch can be applied -SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); - -UPDATE action_trigger.event_definition -SET template = -$$ -[%- -# target is the bookbag itself. The 'items' variable does not need to be in -# the environment because a special reactor will take care of filling it in. - -FOR item IN items; - bibxml = helpers.unapi_bre(item.target_biblio_record_entry, {flesh => '{mra}'}); - title = ""; - FOR part IN bibxml.findnodes('//*[@tag="245"]/*[@code="a" or @code="b"]'); - title = title _ part.textContent; - END; - author = bibxml.findnodes('//*[@tag="100"]/*[@code="a"]').textContent; - item_type = bibxml.findnodes('//*[local-name()="attributes"]/*[local-name()="field"][@name="item_type"]').getAttribute('coded-value'); - pub_date = ""; - FOR pdatum IN bibxml.findnodes('//*[@tag="260"]/*[@code="c"]'); - IF pub_date ; - pub_date = pub_date _ ", " _ pdatum.textContent; - ELSE ; - pub_date = pdatum.textContent; - END; - END; - helpers.csv_datum(title) %],[% helpers.csv_datum(author) %],[% helpers.csv_datum(pub_date) %],[% helpers.csv_datum(item_type) %],[% FOR note IN item.notes; helpers.csv_datum(note.note); ","; END; "\n"; -END -%] -$$ -WHERE id = 48; - -COMMIT;