From 30f2f3114a2d023dd700c28ccdc68ceb2e9ab9d0 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 8 Jan 2014 07:58:14 -0500 Subject: [PATCH] Bug 9303 [QA Followup] - Set AUTO_INCREMENT value for issues.issue_id --- installer/data/mysql/updatedatabase.pl | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index f56e102..2f7ed85 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -37,6 +37,7 @@ use Getopt::Long; use C4::Context; use C4::Installer; use C4::Dates; +use Koha::Database; use MARC::Record; use MARC::File::XML ( BinaryEncoding => 'utf8' ); @@ -7962,6 +7963,16 @@ if(CheckVersion($DBversion)) { $dbh->do(qq{ UPDATE issues SET issue_id = issue_id + ( SELECT COUNT(*) FROM old_issues ) ORDER BY issue_id DESC }); + + my $schema = Koha::Database->new()->schema(); + my $max_issue_id = $schema->resultset('Issue')->get_column('issue_id')->max(); + $max_issue_id ||= $schema->resultset('OldIssue')->get_column('issue_id')->max(); + $max_issue_id ||= 0; + $max_issue_id++; + $dbh->do(qq{ + ALTER TABLE issues AUTO_INCREMENT = $max_issue_id + }); + print "Upgrade to $DBversion done (Bug 9303 - relative's checkouts in the opac)\n"; SetVersion($DBversion); } -- 1.7.2.5