Merge remote-tracking branch 'origin/new/bug_6328'
[srvgit] / installer / data / mysql / updatedatabase.pl
index e901a58..3ff4ba3 100755 (executable)
@@ -4567,10 +4567,23 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
 $DBversion = "3.07.00.002";
 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
     $dbh->do("UPDATE borrowers SET debarred=NULL WHERE debarred='0000-00-00';");
-    print "Setting NULL to debarred where 0000-00-00 is stored (bug 7272)";
+    print "Setting NULL to debarred where 0000-00-00 is stored (bug 7272)\n";
     SetVersion($DBversion);
 }
 
+$DBversion = "3.06.02.001";
+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+    $dbh->do(" UPDATE `message_attributes` SET message_name='Item_Due' WHERE message_name='Item_DUE'");
+    print "Updating message_name in message_attributes\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.06.03.001";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+    $dbh->do("ALTER TABLE  `suggestions` ADD  `patronreason` TEXT NULL AFTER  `reason`");
+    print "Upgrade to $DBversion done (Add column to suggestions table to store patrons' reasons for submitting a suggestion. )\n";
+    SetVersion($DBversion);
+}
 
 =head1 FUNCTIONS
 
@@ -4614,6 +4627,10 @@ sub TransformToNum {
     my $version = shift;
     # remove the 3 last . to have a Perl number
     $version =~ s/(.*\..*)\.(.*)\.(.*)/$1$2$3/;
+    # three X's at the end indicate that you are testing patch with dbrev
+    # change it into 999
+    # prevents error on a < comparison between strings (should be: lt)
+    $version =~ s/XXX$/999/;
     return $version;
 }
 
@@ -4624,7 +4641,9 @@ set the DBversion in the systempreferences
 =cut
 
 sub SetVersion {
-    my $kohaversion = TransformToNum(shift);
+    return if $_[0]=~ /XXX$/;
+      #you are testing a patch with a db revision; do not change version
+    my $kohaversion = TransformToNum($_[0]);
     if (C4::Context->preference('Version')) {
       my $finish=$dbh->prepare("UPDATE systempreferences SET value=? WHERE variable='Version'");
       $finish->execute($kohaversion);