Bug 11334: add ability to control which library fields are used for facets
[koha.git] / installer / data / mysql / atomicupdate / 0001-bug_2929-permit_to_define_fine_days_in_issuing_rules.pl
1 #! /usr/bin/perl
2 use strict;
3 use warnings;
4 use C4::Context;
5 my $dbh=C4::Context->dbh;
6 $dbh->do("ALTER TABLE issuingrules ADD 
7                 COLUMN `finedays` int(11) default NULL AFTER `fine`,
8                 COLUMN `renewalsallowed` smallint(6) default NULL, 
9                 COLUMN `reservesallowed` smallint(6) default NULL,
10                 ");
11 my $sth = $dbh->prepare("SELECT itemtype, renewalsallowed FROM itemtypes");
12 $sth->execute();
13
14 my $sthupd = $dbh->prepare("UPDATE issuingrules SET renewalsallowed = ? WHERE itemtype = ?");
15     
16 while(my $row = $sth->fetchrow_hashref){
17       $sthupd->execute($row->{renewalsallowed}, $row->{itemtype});
18 }
19     
20 $dbh->do('ALTER TABLE itemtypes DROP COLUMN `renewalsallowed`;');
21     
22 print "Upgrade done (Adding finedays renewalsallowed, and reservesallowed fields in issuingrules table)\n";