Bug with update database, was causing finedays not to add, which broke adding issuing...
authorChris Cormack <chris@bigballofwax.co.nz>
Fri, 11 Dec 2009 21:48:01 +0000 (10:48 +1300)
committerChris Cormack <chris@bigballofwax.co.nz>
Thu, 28 Jan 2010 19:45:13 +0000 (08:45 +1300)
installer/data/mysql/updatedatabase.pl

index 41dfa3f..e5ebe4b 100755 (executable)
@@ -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";
 }