Constrain serial.issuance.holding_code to be valid JSON or NULL
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Thu, 5 Apr 2012 15:46:05 +0000 (11:46 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Sat, 28 Apr 2012 19:50:15 +0000 (15:50 -0400)
commitdb61133753257604e93a0be568ee3b9415c56b8c
tree0e01f3652aa34f8fd69a15853d10af4c4ef4452c
parent23449603ef51c77534847e6bcc9e16c5be02b54e
Constrain serial.issuance.holding_code to be valid JSON or NULL

This avoids serial.materialize_holding_code() failing on bad data.  The
upgrade script will actually throw away bad values for
serial.issuance.holding_code.  This is no real loss, since bad data
there prevents any serials functions around the row in question from
working properly anyway.

This problem was reported by Martha Driscoll and Ben Shum.

*Also* put a couple of changes missed from the 0700 upgrade script into
210.schema.serials.sql.

Fix new serial constraint upgrades

1. None of the upgrades so far have moved is_json() from the public
to the evergreen schema.  That's probably a separate issue, but it
should be safe to call it unqualified, and that's what the rest of
the upgrade file does, so we will too.

2. Add a specific SET CONSTRAINT to avoid deferred trigger problems
when ALTERing the table.

3. Make sure that the unwanted columns on materialized_holding_code
do not exist regardless of your upgrade path.

Signed-off-by: Dan Wells <dbw2@calvin.edu>
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/210.schema.serials.sql
Open-ILS/src/sql/Pg/upgrade/0706.schema.serial-holding-code-constraint.sql [new file with mode: 0644]
Open-ILS/src/sql/Pg/version-upgrade/2.1-2.2-upgrade-db.sql