From: Chris Cormack Date: Fri, 11 Dec 2009 21:48:01 +0000 (+1300) Subject: Bug with update database, was causing finedays not to add, which broke adding issuing... X-Git-Tag: v3.02.00-alpha~10^2~16 X-Git-Url: http://git.rot13.org/?a=commitdiff_plain;h=8ed554b3610711c4b22536d6225abe2fc5fd98ae;p=koha.git Bug with update database, was causing finedays not to add, which broke adding issuingrules related to bug 3864 --- diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 41dfa3f515..e5ebe4b2e6 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -2748,8 +2748,17 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { $DBversion = "3.01.00.068"; if (C4::Context->preference("Version") < TransformToNum($DBversion)) { - $dbh->do("ALTER TABLE issuingrules ADD COLUMN `finedays` int(11) default NULL AFTER `fine` "); - print "Upgrade done (Adding finedays in issuingrules table)\n"; + $dbh->do("ALTER TABLE issuingrules ADD COLUMN `finedays` int(11) default NULL AFTER `fine`"); + $dbh->do("ALTER TABLE issuingrules ADD COLUMN `renewalsallowed` smallint(6) default NULL"); + $dbh->do("ALTER TABLE issuingrules ADD COLUMN `reservesallowed` smallint(6) default NULL"); + my $sth = $dbh->prepare("SELECT itemtype, renewalsallowed FROM itemtypes"); + $sth->execute(); + my $sthupd = $dbh->prepare("UPDATE issuingrules SET renewalsallowed = ? WHERE itemtype = ?"); + while(my $row = $sth->fetchrow_hashref){ + $sthupd->execute($row->{renewalsallowed}, $row->{itemtype}); + } + $dbh->do('ALTER TABLE itemtypes DROP COLUMN `renewalsallowed`;'); + print "Upgrade done (Adding finedays renewalsallowed, and reservesallowed fields in issuingrules table)\n"; }