Wrap upgrade script for CSV circ history export
authorDan Scott <dscott@laurentian.ca>
Thu, 22 Mar 2012 16:53:13 +0000 (12:53 -0400)
committerDan Scott <dscott@laurentian.ca>
Thu, 22 Mar 2012 16:53:13 +0000 (12:53 -0400)
Thanks, Bill!

Signed-off-by: Dan Scott <dscott@laurentian.ca>
Open-ILS/src/sql/Pg/upgrade/0688.data.circ_history_export_csv.sql [new file with mode: 0644]
Open-ILS/src/sql/Pg/upgrade/XXXX.data.circ_history_export_csv.sql [deleted file]

diff --git a/Open-ILS/src/sql/Pg/upgrade/0688.data.circ_history_export_csv.sql b/Open-ILS/src/sql/Pg/upgrade/0688.data.circ_history_export_csv.sql
new file mode 100644 (file)
index 0000000..25e451b
--- /dev/null
@@ -0,0 +1,54 @@
+-- Evergreen DB patch 0688.data.circ_history_export_csv.sql
+--
+-- FIXME: insert description of change, if needed
+--
+BEGIN;
+
+-- check whether patch can be applied
+SELECT evergreen.upgrade_deps_block_check('0688', :eg_version);
+
+INSERT INTO action_trigger.hook (key, core_type, description, passive)
+VALUES (
+    'circ.format.history.csv',
+    'circ',
+    oils_i18n_gettext(
+        'circ.format.history.csv',
+        'Produce CSV of circulation history',
+        'ath',
+        'description'
+    ),
+    FALSE
+);
+
+INSERT INTO action_trigger.event_definition (
+    active, owner, name, hook, reactor, validator, group_field, template) 
+VALUES (
+    TRUE, 1, 'Circ History CSV', 'circ.format.history.csv', 'ProcessTemplate', 'NOOP_True', 'usr',
+$$
+Title,Author,Call Number,Barcode,Format
+[%-
+FOR circ IN target;
+    bibxml = helpers.unapi_bre(circ.target_copy.call_number.record, {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') %]
+
+    [%- helpers.csv_datum(title) -%],
+    [%- helpers.csv_datum(author) -%],
+    [%- helpers.csv_datum(circ.target_copy.call_number.label) -%],
+    [%- helpers.csv_datum(circ.target_copy.barcode) -%],
+    [%- helpers.csv_datum(item_type) %]
+[%- END -%]
+$$
+);
+
+INSERT INTO action_trigger.environment (event_def, path)
+    VALUES (
+        currval('action_trigger.event_definition_id_seq'),
+        'target_copy.call_number'
+    );
+
+COMMIT;
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.circ_history_export_csv.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.circ_history_export_csv.sql
deleted file mode 100644 (file)
index 47cad2c..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-
-BEGIN;
-
-INSERT INTO action_trigger.hook (key, core_type, description, passive)
-VALUES (
-    'circ.format.history.csv',
-    'circ',
-    oils_i18n_gettext(
-        'circ.format.history.csv',
-        'Produce CSV of circulation history',
-        'ath',
-        'description'
-    ),
-    FALSE
-);
-
-INSERT INTO action_trigger.event_definition (
-    active, owner, name, hook, reactor, validator, group_field, template) 
-VALUES (
-    TRUE, 1, 'Circ History CSV', 'circ.format.history.csv', 'ProcessTemplate', 'NOOP_True', 'usr',
-$$
-Title,Author,Call Number,Barcode,Format
-[%-
-FOR circ IN target;
-    bibxml = helpers.unapi_bre(circ.target_copy.call_number.record, {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') %]
-
-    [%- helpers.csv_datum(title) -%],
-    [%- helpers.csv_datum(author) -%],
-    [%- helpers.csv_datum(circ.target_copy.call_number.label) -%],
-    [%- helpers.csv_datum(circ.target_copy.barcode) -%],
-    [%- helpers.csv_datum(item_type) %]
-[%- END -%]
-$$
-);
-
-INSERT INTO action_trigger.environment (event_def, path)
-    VALUES (
-        currval('action_trigger.event_definition_id_seq'),
-        'target_copy.call_number'
-    );
-
-COMMIT;
-
-/* UNDO
-DELETE FROM action_trigger.event WHERE event_def = (
-    SELECT id FROM action_trigger.event_definition WHERE hook = 'circ.format.history.csv');
-DELETE FROM action_trigger.event_definition WHERE hook = 'circ.format.history.csv');
-DELETE FROM action_trigger.hook WHERE key = 'circ.format.history.csv';
-*/