From 179ef0f28f7216231a07adb69fc0f3e1e4858d1a Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 20 Nov 2014 11:01:08 -0500 Subject: [PATCH] Bug 1861 [QA Followup] - Don't modify userids, warn if we can't modify the index automatically Signed-off-by: Martin Renvoize --- installer/data/mysql/updatedatabase.pl | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 1fa6250a13..250f776297 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -9610,17 +9610,21 @@ if ( CheckVersion($DBversion) ) { $DBversion = "3.19.00.XXX"; if ( CheckVersion($DBversion) ) { - $dbh->do(q{ - UPDATE borrowers SET userid = NULL where userid = "" - }); + my ($count) = $dbh->selectrow_array("SELECT COUNT(*) FROM borrowers GROUP BY userid HAVING COUNT(userid) > 1"); - $dbh->do(q{ - ALTER TABLE borrowers - DROP INDEX userid , - ADD UNIQUE userid (userid) - }); + if ( $count ) { + print "Upgrade to $DBversion done (Bug 1861 - Unique patrons logins not (totally) enforced) FAILED!\n"; + print "Your database has users with duplicate user logins. Please have your administrator deduplicate your user logins.\n"; + print "Afterward, your Koha administrator should execute the following database query: ALTER TABLE borrowers DROP INDEX userid, ADD UNIQUE userid (userid)"; + } else { + $dbh->do(q{ + ALTER TABLE borrowers + DROP INDEX userid , + ADD UNIQUE userid (userid) + }); + print "Upgrade to $DBversion done (Bug 1861 - Unique patrons logins not (totally) enforced)\n"; + } - print "Upgrade to $DBversion done (Bug 1861 - Unique patrons logins not (totally) enforced)\n"; SetVersion($DBversion); } -- 2.39.5