Bug 6868 - Need a script to fix bad accountno data in accountlines
Summary: Need a script to fix bad accountno data in accountlines
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Patrons (show other bugs)
Version: 3.6
Hardware: All All
: P3 normal (vote)
Assignee: Ian Walls
QA Contact: Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-14 18:39 UTC by Liz Rea
Modified: 2017-06-14 22:11 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Cleanup Script for accountlines (2.69 KB, application/x-perl)
2011-09-14 20:07 UTC, Ian Walls
Details
Bug 6868 : Script to clean up accountno (3.85 KB, patch)
2011-12-02 06:25 UTC, Chris Cormack
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Liz Rea 2011-09-14 18:39:35 UTC
A pretty serious, and heretofore unidentified bug was causing the accountlines.accountno to increment based on the max accountno in the entire accountlines table. This would cause the SMALL_INT to reach max far more quickly than it should have. The bug that caused the problem was fixed with the patch that was submitted and pushed for bug 3498, but that wouldn't repair the problem in the data - each borrowernumber should have 32767 lines available to it, but in all databases that have been privy to this bug, that wouldn't be correct - numbers would have been skipped based on the max accountno at the time of the writeoff.

What is needed is a script to clean up the accountno for each borrower, to increment it correctly and free all remaining available lines for each borrower.
Comment 1 Ian Walls 2011-09-14 20:07:25 UTC
Created attachment 5429 [details]
Cleanup Script for accountlines

This script cleans up damage to the accountlines table caused by the writeoff() subroutine in members/pay.pl (pre bug 3498 integration).

Includes two flags:

-t  Runs this in test mode.  The database is not actually updated; if omitted, the changes run on database directly.
-v  Prints out every change made to screen; if omitted, just shows progress counter

This script can take some time to run; 8000 updates in 5:30 minutes on a powerful system, in my experience.
Comment 2 Owen Leonard 2011-11-04 19:35:19 UTC
Shouldn't this attachment be formatted as a patch?

Is there a way to create the conditions necessary to test this patch on a system which doesn't have the problem?
Comment 3 Chris Cormack 2011-12-02 06:25:25 UTC
Created attachment 6505 [details] [review]
Bug 6868 : Script to clean up accountno

This script cleans up damage to the accountlines table caused by the
writeoff()
subroutine in members/pay.pl (pre bug 3498 integration).

Includes two flags:

-t  Runs this in test mode.  The database is not actually updated; if
omitted, the changes run on database directly.

-v  Prints out every change made to screen; if omitted, just shows
progress counter

This script can take some time to run; 8000 updates in 5:30 minutes on a
powerful system, in my experience.
Comment 4 Katrin Fischer 2011-12-06 07:20:34 UTC
I am not sure how to test this. Can you provide a test plan?
Comment 5 Chris Cormack 2011-12-06 21:47:20 UTC
Hi Katrin

The error was if you had over 32000ish accounts then the number had hit its max.


Its pretty hard to test, you would have to get a create a borrower over that many lines in accountlines.
Comment 6 Liz Rea 2011-12-07 15:42:44 UTC
Also, I'm not so sure this really needs to be somehow integrated into Koha? Perhaps just having the script available for people to download and use is enough?
Comment 7 Chris Cormack 2011-12-08 01:10:56 UTC
Good point, maybe a link to this bug/patch on the wiki ?
Comment 8 Chris Cormack 2011-12-31 06:48:21 UTC
Script won't be pushed, leaving open for people who need it to be able to find it
Comment 9 Owen Leonard 2016-08-10 16:02:58 UTC
I think the version which caused this problem is old enough that we can close this bug.