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:51:19 +0000 (15:51 -0400)
commitaf3f2e21273694d1acdc30ab92a544a0fb109182
tree34ae45b1378568e9ea673263e6c301d409b98310
parente68fb0bda30287417a0066b6a41f3b426735c4e2
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