[Koha-patches] [Signed Off] [PATCH] Bug 4002: issues table referential integrity
Mike Hafen
mdhafen at tech.washk12.org
Mon May 16 18:26:15 CEST 2011
Looks like you are selecting from the wrong table here... borrowers should
be items
On Mon, May 16, 2011 at 1:30 AM, Chris Cormack <chris at bigballofwax.co.nz>wrote:
> From: Srdjan Jankovic <srdjan at catalyst.net.nz>
>
> This patch fixes rows in the issues table that have null borrower or item
> numbers
> And stops this being able to happen in the future
>
> Signed-off-by: Chris Cormack <chris at bigballofwax.co.nz>
> ---
>
+ $dbh->do("INSERT INTO old_issues (borrowernumber, itemnumber, date_due,
branchcode, issuingbranch, returndate, lastreneweddate, `return`, renewals,
timestamp, issuedate)
+ SELECT borrowernumber, itemnumber, date_due, branchcode,
issuingbranch, returndate, lastreneweddate, `return`, renewals, timestamp,
issuedate FROM issues WHERE NOT EXISTS (SELECT * FROM borrowers WHERE
itemnumber = issues.itemnumber)");
+ $dbh->do("DELETE FROM issues WHERE NOT EXISTS (SELECT * FROM items
WHERE itemnumber = issues.itemnumber)");
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/koha-patches/attachments/20110516/eab43e30/attachment.htm>
More information about the Koha-patches
mailing list