[OPEN-ILS-DEV] precat error

Jason Etheridge jason at esilibrary.com
Sun Oct 10 12:26:06 EDT 2010


On Sun, Oct 10, 2010 at 11:32 AM, Kim Scannell <kscannell at cntrmail.org> wrote:
> Thanks Jason, I tried to checkout a precat as admin and got the same error.
> Error log says:
>  insert or update on table "copy" violates foreign key constraint
> "copy_location_fkey"
> 2010-10-09 18:29:10 CDT DETAIL:  Key (location)=(1) is not present in
> table "copy_location".

Ah, that explains it.  The precat code is trying to create an item
with a copy/shelving location that no longer exists in your
installation.  This is a hardcoded value, so the easiest fix is insert
such a row directly into the database.  In a stock Evergreen
installation, this location would be called Stacks.  You could also
change the id for one of your existing locations to 1, but that's not
as easy as it could be.

This should be safe to enter into psql, but if it blows up your
database or something, just don't come after me. :-)  Always a good
idea to do such things after business hours and to have a fresh
backup.

BEGIN;
UPDATE asset.copy_location SET id = 1 WHERE id = 114; -- this moves
your existing Stacks from 114 to 1
UPDATE asset.copy SET location = 1 WHERE location = 114; -- this
mirrors the change amongst your items
COMMIT; -- this makes it all happen, and until this is entered, your
tables may be locked, affecting production use

-- 
Jason Etheridge
 | VP, Tactical Development
 | Equinox Software, Inc. / Your Library's Guide to Open Source
 | phone:  1-877-OPEN-ILS (673-6457)
 | email:  jason at esilibrary.com
 | web:  http://www.esilibrary.com

Happy 4th birthday, Evergreen!


More information about the Open-ils-dev mailing list