[open-ils-commits] [GIT] Evergreen ILS branch rel_2_3 updated. 0cbff297cc45f057105a9779e96bd1cc427a6c6b
Evergreen Git
git at git.evergreen-ils.org
Mon Mar 11 16:27:00 EDT 2013
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_3 has been updated
via 0cbff297cc45f057105a9779e96bd1cc427a6c6b (commit)
via 302e1bc0f09ea24b7c9449c33cb13acc86e417a0 (commit)
from 9a082a5f6d66c96a057015e9207882ca94e53814 (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 0cbff297cc45f057105a9779e96bd1cc427a6c6b
Author: Mike Rylander <mrylander at gmail.com>
Date: Mon Mar 11 16:22:38 2013 -0400
Stamping upgrade for serials harmonization
Signed-off-by: Mike Rylander <mrylander at gmail.com>
diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index fdc93e9..8bbae74 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 ('0766', :eg_version); -- gmcharlt/miker
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0767', :eg_version); -- senator/miker
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.serials-holding-code-test-improved.sql b/Open-ILS/src/sql/Pg/upgrade/0767.schema.serials-holding-code-test-improved.sql
similarity index 94%
rename from Open-ILS/src/sql/Pg/upgrade/XXXX.schema.serials-holding-code-test-improved.sql
rename to Open-ILS/src/sql/Pg/upgrade/0767.schema.serials-holding-code-test-improved.sql
index d1c3c38..378bdfc 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.serials-holding-code-test-improved.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/0767.schema.serials-holding-code-test-improved.sql
@@ -1,6 +1,6 @@
BEGIN;
-SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+SELECT evergreen.upgrade_deps_block_check('0767', :eg_version);
CREATE OR REPLACE FUNCTION evergreen.could_be_serial_holding_code(TEXT) RETURNS BOOL AS $$
use JSON::XS;
commit 302e1bc0f09ea24b7c9449c33cb13acc86e417a0
Author: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>
Date: Tue Oct 23 12:25:18 2012 -0400
Fix divergence of stock serials schema and upgraded schema
And additionally make a function used in a constraint on
serial.issuance.holding_code a little bit smarter.
These issues were reported to me by Galen Charlton.
The upgrade script included here will set serial.issuance.holding_code
to NULL in cases where the value doesn't validate, but in those cases
there is no part of Evergreen that could have made use of the data
anyway, and the data is just plain bad.
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>
Signed-off-by: Mike Rylander <mrylander at gmail.com>
diff --git a/Open-ILS/src/sql/Pg/000.functions.general.sql b/Open-ILS/src/sql/Pg/000.functions.general.sql
index ffbc629..51ce2b7 100644
--- a/Open-ILS/src/sql/Pg/000.functions.general.sql
+++ b/Open-ILS/src/sql/Pg/000.functions.general.sql
@@ -57,4 +57,23 @@ $func$;
COMMENT ON FUNCTION evergreen.xml_pretty_print(input XML) IS
'Simple pretty printer for XML, as written by Andrew Dunstan at http://goo.gl/zBHIk';
+CREATE OR REPLACE FUNCTION evergreen.could_be_serial_holding_code(TEXT) RETURNS BOOL AS $$
+ use JSON::XS;
+ use MARC::Field;
+
+ eval {
+ my $holding_code = (new JSON::XS)->decode(shift);
+ new MARC::Field('999', @$holding_code);
+ };
+ return 0 if $@;
+ # verify that subfield labels are exactly one character long
+ foreach (keys %{ { @$holding_code } }) {
+ return 0 if length($_) != 1;
+ }
+ return 1;
+$$ LANGUAGE PLPERLU;
+
+COMMENT ON FUNCTION evergreen.could_be_serial_holding_code(TEXT) IS
+ 'Return true if parameter is valid JSON representing an array that at minimum doesn''t make MARC::Field balk and only has subfield labels exactly one character long. Otherwise false.';
+
COMMIT;
diff --git a/Open-ILS/src/sql/Pg/210.schema.serials.sql b/Open-ILS/src/sql/Pg/210.schema.serials.sql
index 39fb75e..d025d5e 100644
--- a/Open-ILS/src/sql/Pg/210.schema.serials.sql
+++ b/Open-ILS/src/sql/Pg/210.schema.serials.sql
@@ -193,7 +193,9 @@ CREATE TABLE serial.issuance (
date_published TIMESTAMP WITH TIME ZONE,
caption_and_pattern INT REFERENCES serial.caption_and_pattern (id)
DEFERRABLE INITIALLY DEFERRED,
- holding_code TEXT,
+ holding_code TEXT CONSTRAINT issuance_holding_code_check CHECK (
+ holding_code IS NULL OR could_be_serial_holding_code(holding_code)
+ ),
holding_type TEXT CONSTRAINT valid_holding_type CHECK
(
holding_type IS NULL
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.serials-holding-code-test-improved.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.serials-holding-code-test-improved.sql
new file mode 100644
index 0000000..d1c3c38
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.serials-holding-code-test-improved.sql
@@ -0,0 +1,38 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+CREATE OR REPLACE FUNCTION evergreen.could_be_serial_holding_code(TEXT) RETURNS BOOL AS $$
+ use JSON::XS;
+ use MARC::Field;
+
+ eval {
+ my $holding_code = (new JSON::XS)->decode(shift);
+ new MARC::Field('999', @$holding_code);
+ };
+ return 0 if $@;
+ # verify that subfield labels are exactly one character long
+ foreach (keys %{ { @$holding_code } }) {
+ return 0 if length($_) != 1;
+ }
+ return 1;
+$$ LANGUAGE PLPERLU;
+
+COMMENT ON FUNCTION evergreen.could_be_serial_holding_code(TEXT) IS
+ 'Return true if parameter is valid JSON representing an array that at minimu
+m doesn''t make MARC::Field balk and only has subfield labels exactly one character long. Otherwise false.';
+
+
+-- This UPDATE throws away data, but only bad data that makes things break
+-- anyway.
+UPDATE serial.issuance
+ SET holding_code = NULL
+ WHERE NOT could_be_serial_holding_code(holding_code);
+
+ALTER TABLE serial.issuance
+ DROP CONSTRAINT IF EXISTS issuance_holding_code_check;
+
+ALTER TABLE serial.issuance
+ ADD CHECK (holding_code IS NULL OR could_be_serial_holding_code(holding_code));
+
+COMMIT;
-----------------------------------------------------------------------
Summary of changes:
Open-ILS/src/sql/Pg/000.functions.general.sql | 19 ++++++++++
Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +-
Open-ILS/src/sql/Pg/210.schema.serials.sql | 4 ++-
...7.schema.serials-holding-code-test-improved.sql | 38 ++++++++++++++++++++
4 files changed, 61 insertions(+), 2 deletions(-)
create mode 100644 Open-ILS/src/sql/Pg/upgrade/0767.schema.serials-holding-code-test-improved.sql
hooks/post-receive
--
Evergreen ILS
More information about the open-ils-commits
mailing list