Bug 11577: Add auto_renew flags to the database
authorHolger Meißner <h.meissner.82@web.de>
Thu, 15 May 2014 14:18:36 +0000 (16:18 +0200)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Wed, 17 Sep 2014 22:23:05 +0000 (19:23 -0300)
- issues.auto_renew
- old_issues.auto_renew
- issuingrules.auto_renew

Default value is zero.

To test:

1) Run installer/data/mysql/updatedatabase.pl
2) Create SQL reports like:
   SELECT * FROM issues LIMIT 0,1
3) Confirm that a column auto_renew was added to each of the three tables.

Sponsored-by: Hochschule für Gesundheit (hsg), Germany
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
installer/data/mysql/kohastructure.sql
installer/data/mysql/updatedatabase.pl

index 54ac922..aeeba17 100644 (file)
@@ -1123,6 +1123,7 @@ CREATE TABLE `issues` ( -- information related to check outs or issues
   `lastreneweddate` datetime default NULL, -- date the item was last renewed
   `return` varchar(4) default NULL,
   `renewals` tinyint(4) default NULL, -- lists the number of times the item was renewed
+  `auto_renew` BOOLEAN default FALSE, -- automatic renewal
   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this record was last touched
   `issuedate` datetime default NULL, -- date the item was checked out or issued
   KEY `issuesborridx` (`borrowernumber`),
@@ -1160,6 +1161,7 @@ CREATE TABLE `issuingrules` ( -- circulation and fine rules
   `renewalsallowed` smallint(6) NOT NULL default "0", -- how many renewals are allowed
   `renewalperiod` int(4) default NULL, -- renewal period in the unit set in issuingrules.lengthunit
   `norenewalbefore` int(4) default NULL, -- no renewal allowed until X days or hours before due date. In the unit set in issuingrules.lengthunit
+  `auto_renew` BOOLEAN default FALSE, -- automatic renewal
   `reservesallowed` smallint(6) NOT NULL default "0", -- how many holds are allowed
   `branchcode` varchar(10) NOT NULL default '', -- the branch this rule is for (branches.branchcode)
   overduefinescap decimal(28,6) default NULL, -- the maximum amount of an overdue fine
@@ -1594,6 +1596,7 @@ CREATE TABLE `old_issues` ( -- lists items that were checked out and have been r
   `lastreneweddate` datetime default NULL, -- date the item was last renewed
   `return` varchar(4) default NULL,
   `renewals` tinyint(4) default NULL, -- lists the number of times the item was renewed
+  `auto_renew` BOOLEAN default FALSE, -- automatic renewal
   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this record was last touched
   `issuedate` datetime default NULL, -- date the item was checked out or issued
   KEY `old_issuesborridx` (`borrowernumber`),
index bfe5f71..edfcbe9 100755 (executable)
@@ -8751,6 +8751,21 @@ if ( CheckVersion($DBversion) ) {
     SetVersion($DBversion);
 }
 
+$DBversion = "3.17.00.XXX";
+if(CheckVersion($DBversion)) {
+    $dbh->do(q{
+        ALTER TABLE issues ADD auto_renew BOOLEAN default FALSE AFTER renewals
+    });
+    $dbh->do(q{
+        ALTER TABLE old_issues ADD auto_renew BOOLEAN default FALSE AFTER renewals
+    });
+    $dbh->do(q{
+        ALTER TABLE issuingrules ADD auto_renew BOOLEAN default FALSE AFTER norenewalbefore
+    });
+    print "Upgrade to $DBversion done (Bug 11577: [ENH] Automatic renewal feature)\n";
+    SetVersion($DBversion);
+}
+
 =head1 FUNCTIONS
 
 =head2 TableExists($table)