[open-ils-commits] [GIT] Evergreen ILS branch rel_2_9 updated. bea2cddccfc17fcadeadf2c7c893b44aa43bd224
Evergreen Git
git at git.evergreen-ils.org
Fri Feb 19 12:36:25 EST 2016
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".
The branch, rel_2_9 has been updated
via bea2cddccfc17fcadeadf2c7c893b44aa43bd224 (commit)
from 862bfb900db4be48c6aabf534e6d748f3f562aa1 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit bea2cddccfc17fcadeadf2c7c893b44aa43bd224
Author: Bill Erickson <berickxx at gmail.com>
Date: Fri Feb 19 12:35:42 2016 -0500
Porting 2.8.4-2.8.5 / 2.8.5-2.8.6 DB upgrade scripts
Signed-off-by: Bill Erickson <berickxx at gmail.com>
diff --git a/Open-ILS/src/sql/Pg/version-upgrade/2.8.4-2.8.5-upgrade-db.sql b/Open-ILS/src/sql/Pg/version-upgrade/2.8.4-2.8.5-upgrade-db.sql
new file mode 100644
index 0000000..aa3e899
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/version-upgrade/2.8.4-2.8.5-upgrade-db.sql
@@ -0,0 +1,161 @@
+--Upgrade Script for 2.8.4 to 2.8.5
+\set eg_version '''2.8.5'''
+BEGIN;
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('2.8.5', :eg_version);
+
+SELECT evergreen.upgrade_deps_block_check('0948', :eg_version);
+
+ALTER TABLE biblio.monograph_part ADD COLUMN deleted BOOL NOT NULL DEFAULT FALSE;
+CREATE RULE protect_mono_part_delete AS ON DELETE TO biblio.monograph_part DO INSTEAD (
+ UPDATE biblio.monograph_part SET deleted = TRUE WHERE OLD.id = biblio.monograph_part.id;
+ DELETE FROM asset.copy_part_map WHERE part = OLD.id
+);
+
+CREATE OR REPLACE FUNCTION unapi.holdings_xml (
+ bid BIGINT,
+ ouid INT,
+ org TEXT,
+ depth INT DEFAULT NULL,
+ includes TEXT[] DEFAULT NULL::TEXT[],
+ slimit HSTORE DEFAULT NULL,
+ soffset HSTORE DEFAULT NULL,
+ include_xmlns BOOL DEFAULT TRUE,
+ pref_lib INT DEFAULT NULL
+)
+RETURNS XML AS $F$
+ SELECT XMLELEMENT(
+ name holdings,
+ XMLATTRIBUTES(
+ CASE WHEN $8 THEN 'http://open-ils.org/spec/holdings/v1' ELSE NULL END AS xmlns,
+ CASE WHEN ('bre' = ANY ($5)) THEN 'tag:open-ils.org:U2 at bre/' || $1 || '/' || $3 ELSE NULL END AS id,
+ (SELECT record_has_holdable_copy FROM asset.record_has_holdable_copy($1)) AS has_holdable
+ ),
+ XMLELEMENT(
+ name counts,
+ (SELECT XMLAGG(XMLELEMENT::XML) FROM (
+ SELECT XMLELEMENT(
+ name count,
+ XMLATTRIBUTES('public' as type, depth, org_unit, coalesce(transcendant,0) as transcendant, available, visible as count, unshadow)
+ )::text
+ FROM asset.opac_ou_record_copy_count($2, $1)
+ UNION
+ SELECT XMLELEMENT(
+ name count,
+ XMLATTRIBUTES('staff' as type, depth, org_unit, coalesce(transcendant,0) as transcendant, available, visible as count, unshadow)
+ )::text
+ FROM asset.staff_ou_record_copy_count($2, $1)
+ UNION
+ SELECT XMLELEMENT(
+ name count,
+ XMLATTRIBUTES('pref_lib' as type, depth, org_unit, coalesce(transcendant,0) as transcendant, available, visible as count, unshadow)
+ )::text
+ FROM asset.opac_ou_record_copy_count($9, $1)
+ ORDER BY 1
+ )x)
+ ),
+ CASE
+ WHEN ('bmp' = ANY ($5)) THEN
+ XMLELEMENT(
+ name monograph_parts,
+ (SELECT XMLAGG(bmp) FROM (
+ SELECT unapi.bmp( id, 'xml', 'monograph_part', evergreen.array_remove_item_by_value( evergreen.array_remove_item_by_value($5,'bre'), 'holdings_xml'), $3, $4, $6, $7, FALSE)
+ FROM biblio.monograph_part
+ WHERE NOT deleted AND record = $1
+ )x)
+ )
+ ELSE NULL
+ END,
+ XMLELEMENT(
+ name volumes,
+ (SELECT XMLAGG(acn ORDER BY rank, name, label_sortkey) FROM (
+ -- Physical copies
+ SELECT unapi.acn(y.id,'xml','volume',evergreen.array_remove_item_by_value( evergreen.array_remove_item_by_value($5,'holdings_xml'),'bre'), $3, $4, $6, $7, FALSE), y.rank, name, label_sortkey
+ FROM evergreen.ranked_volumes($1, $2, $4, $6, $7, $9, $5) AS y
+ UNION ALL
+ -- Located URIs
+ SELECT unapi.acn(uris.id,'xml','volume',evergreen.array_remove_item_by_value( evergreen.array_remove_item_by_value($5,'holdings_xml'),'bre'), $3, $4, $6, $7, FALSE), uris.rank, name, label_sortkey
+ FROM evergreen.located_uris($1, $2, $9) AS uris
+ )x)
+ ),
+ CASE WHEN ('ssub' = ANY ($5)) THEN
+ XMLELEMENT(
+ name subscriptions,
+ (SELECT XMLAGG(ssub) FROM (
+ SELECT unapi.ssub(id,'xml','subscription','{}'::TEXT[], $3, $4, $6, $7, FALSE)
+ FROM serial.subscription
+ WHERE record_entry = $1
+ )x)
+ )
+ ELSE NULL END,
+ CASE WHEN ('acp' = ANY ($5)) THEN
+ XMLELEMENT(
+ name foreign_copies,
+ (SELECT XMLAGG(acp) FROM (
+ SELECT unapi.acp(p.target_copy,'xml','copy',evergreen.array_remove_item_by_value($5,'acp'), $3, $4, $6, $7, FALSE)
+ FROM biblio.peer_bib_copy_map p
+ JOIN asset.copy c ON (p.target_copy = c.id)
+ WHERE NOT c.deleted AND p.peer_record = $1
+ LIMIT ($6 -> 'acp')::INT
+ OFFSET ($7 -> 'acp')::INT
+ )x)
+ )
+ ELSE NULL END
+ );
+$F$ LANGUAGE SQL STABLE;
+
+CREATE OR REPLACE FUNCTION unapi.bmp ( obj_id BIGINT, format TEXT, ename TEXT, includes TEXT[], org TEXT, depth INT DEFAULT NULL, slimit HSTORE DEFAULT NULL, soffset HSTORE DEFAULT NULL, include_xmlns BOOL DEFAULT TRUE ) RETURNS XML AS $F$
+ SELECT XMLELEMENT(
+ name monograph_part,
+ XMLATTRIBUTES(
+ CASE WHEN $9 THEN 'http://open-ils.org/spec/holdings/v1' ELSE NULL END AS xmlns,
+ 'tag:open-ils.org:U2 at bmp/' || id AS id,
+ id AS ident,
+ label,
+ label_sortkey,
+ 'tag:open-ils.org:U2 at bre/' || record AS record
+ ),
+ CASE
+ WHEN ('acp' = ANY ($4)) THEN
+ XMLELEMENT( name copies,
+ (SELECT XMLAGG(acp) FROM (
+ SELECT unapi.acp( cp.id, 'xml', 'copy', evergreen.array_remove_item_by_value($4,'bmp'), $5, $6, $7, $8, FALSE)
+ FROM asset.copy cp
+ JOIN asset.copy_part_map cpm ON (cpm.target_copy = cp.id)
+ WHERE cpm.part = $1
+ AND cp.deleted IS FALSE
+ ORDER BY COALESCE(cp.copy_number,0), cp.barcode
+ LIMIT ($7 -> 'acp')::INT
+ OFFSET ($8 -> 'acp')::INT
+
+ )x)
+ )
+ ELSE NULL
+ END,
+ CASE WHEN ('bre' = ANY ($4)) THEN unapi.bre( record, 'marcxml', 'record', evergreen.array_remove_item_by_value($4,'bmp'), $5, $6, $7, $8, FALSE) ELSE NULL END
+ )
+ FROM biblio.monograph_part
+ WHERE NOT deleted AND id = $1
+ GROUP BY id, label, label_sortkey, record;
+$F$ LANGUAGE SQL STABLE;
+
+
+
+SELECT evergreen.upgrade_deps_block_check('0949', :eg_version);
+
+CREATE OR REPLACE FUNCTION evergreen.protect_reserved_rows_from_delete() RETURNS trigger AS $protect_reserved$
+BEGIN
+IF OLD.id < TG_ARGV[0]::INT THEN
+ RAISE EXCEPTION 'Cannot delete row with reserved ID %', OLD.id;
+END IF;
+END
+$protect_reserved$
+LANGUAGE plpgsql;
+
+DROP TRIGGER IF EXISTS acq_no_deleted_reserved_cancel_reasons ON acq.cancel_reason;
+
+CREATE TRIGGER acq_no_deleted_reserved_cancel_reasons BEFORE DELETE ON acq.cancel_reason
+ FOR EACH ROW EXECUTE PROCEDURE evergreen.protect_reserved_rows_from_delete(2000);
+
+ALTER TABLE acq.cancel_reason ENABLE TRIGGER acq_no_deleted_reserved_cancel_reasons;
+
+COMMIT;
diff --git a/Open-ILS/src/sql/Pg/version-upgrade/2.8.5-2.8.6-upgrade-db.sql b/Open-ILS/src/sql/Pg/version-upgrade/2.8.5-2.8.6-upgrade-db.sql
new file mode 100644
index 0000000..5335180
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/version-upgrade/2.8.5-2.8.6-upgrade-db.sql
@@ -0,0 +1,35 @@
+--Upgrade Script for 2.8.5 to 2.8.6
+\set eg_version '''2.8.6'''
+BEGIN;
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('2.8.6', :eg_version);
+
+SELECT evergreen.upgrade_deps_block_check('0950', :eg_version);
+
+CREATE OR REPLACE FUNCTION money.materialized_summary_billing_del () RETURNS TRIGGER AS $$
+DECLARE
+ prev_billing money.billing%ROWTYPE;
+ old_billing money.billing%ROWTYPE;
+BEGIN
+ SELECT * INTO prev_billing FROM money.billing WHERE xact = OLD.xact AND NOT voided ORDER BY billing_ts DESC LIMIT 1 OFFSET 1;
+ SELECT * INTO old_billing FROM money.billing WHERE xact = OLD.xact AND NOT voided ORDER BY billing_ts DESC LIMIT 1;
+
+ IF OLD.id = old_billing.id THEN
+ UPDATE money.materialized_billable_xact_summary
+ SET last_billing_ts = prev_billing.billing_ts,
+ last_billing_note = prev_billing.note,
+ last_billing_type = prev_billing.billing_type
+ WHERE id = OLD.xact;
+ END IF;
+
+ IF NOT OLD.voided THEN
+ UPDATE money.materialized_billable_xact_summary
+ SET total_owed = total_owed - OLD.amount,
+ balance_owed = balance_owed - OLD.amount
+ WHERE id = OLD.xact;
+ END IF;
+
+ RETURN OLD;
+END;
+$$ LANGUAGE PLPGSQL;
+
+COMMIT;
-----------------------------------------------------------------------
Summary of changes:
...1-upgrade-db.sql => 2.8.4-2.8.5-upgrade-db.sql} | 6 +++---
...2-upgrade-db.sql => 2.8.5-2.8.6-upgrade-db.sql} | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)
copy Open-ILS/src/sql/Pg/version-upgrade/{2.9.0-2.9.1-upgrade-db.sql => 2.8.4-2.8.5-upgrade-db.sql} (98%)
copy Open-ILS/src/sql/Pg/version-upgrade/{2.9.1-2.9.2-upgrade-db.sql => 2.8.5-2.8.6-upgrade-db.sql} (93%)
hooks/post-receive
--
Evergreen ILS
More information about the open-ils-commits
mailing list