From 8ed554b3610711c4b22536d6225abe2fc5fd98ae Mon Sep 17 00:00:00 2001 From: Chris Cormack Date: Sat, 12 Dec 2009 10:48:01 +1300 Subject: [PATCH] Bug with update database, was causing finedays not to add, which broke adding issuingrules related to bug 3864 --- installer/data/mysql/updatedatabase.pl | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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"; } -- 2.39.5