From: senator Date: Tue, 6 Jul 2010 13:44:59 +0000 (+0000) Subject: Booking: fixed the last db upgrade script. It was trying to insert a row X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=1b0e7d019b9049ed5b533b6e783e88a4360b992e;p=evergreen%2Ftadl.git Booking: fixed the last db upgrade script. It was trying to insert a row in config.org_unit_setting_type that had already been covered by 0109, but which had not been in the seed data until recently, so I think one would have only noticed this if hadn't installed a new schema from scratch in some time. If you already ran 0323 and it worked for you, you don't have to do anything. Also, this now avoids clobbering already-set default_elbow_room values. git-svn-id: svn://svn.open-ils.org/ILS/trunk@16847 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/sql/Pg/upgrade/0323.data.booking.elbow_room.sql b/Open-ILS/src/sql/Pg/upgrade/0323.data.booking.elbow_room.sql index 514c056cc4..b48cccc45a 100644 --- a/Open-ILS/src/sql/Pg/upgrade/0323.data.booking.elbow_room.sql +++ b/Open-ILS/src/sql/Pg/upgrade/0323.data.booking.elbow_room.sql @@ -1,13 +1,8 @@ -BEGIN; - -INSERT INTO config.upgrade_log (version) VALUES ('0323'); -- senator - --- In booking, elbow room defines: --- a) how far in the future you must make a reservation on a given item if --- that item will have to transit somewhere to fulfill the reservation. --- b) how soon a reservation must be starting for the reserved item to --- be op-captured by the checkin interface. - +-- This statement ok to fail if the row is already there in coust. You will +-- already have this if you have a +-- very old trunk installation (because this has been added by an earlier +-- upgrade script (0109), but has not been in the default seed data until +-- recently INSERT INTO config.org_unit_setting_type (name, label, description, datatype) VALUES ( 'circ.booking_reservation.default_elbow_room', @@ -26,10 +21,35 @@ INSERT INTO config.org_unit_setting_type 'interval' ); -INSERT INTO actor.org_unit_setting (org_unit, name, value) VALUES ( - (SELECT id FROM actor.org_unit WHERE parent_ou IS NULL), - 'circ.booking_reservation.default_elbow_room', - '"1 day"' -); +BEGIN; + +INSERT INTO config.upgrade_log (version) VALUES ('0323'); -- senator + +-- In booking, elbow room defines: +-- a) how far in the future you must make a reservation on a given item if +-- that item will have to transit somewhere to fulfill the reservation. +-- b) how soon a reservation must be starting for the reserved item to +-- be op-captured by the checkin interface. + +-- We don't want to clobber any default_elbow room at any level: + +CREATE OR REPLACE FUNCTION pg_temp.default_elbow() RETURNS INTEGER AS $$ +DECLARE + existing actor.org_unit_setting%ROWTYPE; +BEGIN + SELECT INTO existing id FROM actor.org_unit_setting WHERE name = 'circ.booking_reservation.default_elbow_room'; + IF NOT FOUND THEN + INSERT INTO actor.org_unit_setting (org_unit, name, value) VALUES ( + (SELECT id FROM actor.org_unit WHERE parent_ou IS NULL), + 'circ.booking_reservation.default_elbow_room', + '"1 day"' + ); + RETURN 1; + END IF; + RETURN 0; +END; +$$ LANGUAGE plpgsql; + +SELECT pg_temp.default_elbow(); COMMIT;