From: Bill Erickson Date: Fri, 25 Oct 2013 16:18:35 +0000 (-0400) Subject: ff : sql mods file repairs X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=14ac1899c73b18cc4161c44fa9cc4687c107f479;p=evergreen%2Fequinox.git ff : sql mods file repairs Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/sql/Pg/fulfillment-mods.sql b/Open-ILS/src/sql/Pg/fulfillment-mods.sql index 8b85228f46..2861fa4d6b 100644 --- a/Open-ILS/src/sql/Pg/fulfillment-mods.sql +++ b/Open-ILS/src/sql/Pg/fulfillment-mods.sql @@ -4,25 +4,39 @@ BEGIN; -- Altered Tables ------------------------------------------------------------ ALTER TABLE actor.card - ADD COLUMN org INT NOT NULL + ADD COLUMN org INT NOT NULL DEFAULT 1 REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED; CREATE UNIQUE INDEX actor_card_barcode_org_idx ON actor.card (barcode, org); ALTER TABLE asset.copy - ADD COLUMN source_lib INT NOT NULL + ADD COLUMN source_lib INT NOT NULL DEFAULT 1 REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED; -DROP INDEX IF EXISTS copy_barcode_key; +DROP INDEX IF EXISTS asset.copy_barcode_key; CREATE UNIQUE INDEX copy_barcode_key ON asset.copy (barcode, source_lib) WHERE deleted = FALSE OR deleted IS FALSE; -ALTER TABLE biblio.record_entry - ADD COLUMN remote_id TEXT; +ALTER TABLE biblio.record_entry ADD COLUMN remote_id TEXT; CREATE INDEX biblio_record_entry_remote_id_owner_idx - ON biblio.record_entry ( remote_id, owner ); + ON biblio.record_entry (remote_id, owner); +-- Altered Tables / Default Values ------------------------------------------- + +-- update existing seed data with more sane default values for our new org +-- unit columns. + +-- this should really be the root org unit of the ILL partner, not the +-- user's home org unit. +UPDATE actor.card ac SET org = + (SELECT home_ou FROM actor.usr usr WHERE usr.id = ac.usr); + +UPDATE asset.copy acp SET source_lib = + (CASE bre.owner::BOOLEAN WHEN NOT NULL THEN bre.owner ELSE acn.owning_lib END) + FROM biblio.record_entry bre + JOIN asset.call_number acn on (bre.id = acn.record) + WHERE acp.call_number = acn.id; -- New Tables ---------------------------------------------------------------- @@ -862,3 +876,4 @@ INSERT INTO actor.web_action_print_template $$); COMMIT; +--ROLLBACK;