follow-up: fixing mistake in database revision number
authorPaul Poulain <paul.poulain@biblibre.com>
Fri, 6 Jan 2012 09:50:48 +0000 (10:50 +0100)
committerPaul Poulain <paul.poulain@biblibre.com>
Fri, 6 Jan 2012 09:50:48 +0000 (10:50 +0100)
After long discussion with chris_c (previous RM) and chris_n (previous and actual RMaint), it appears I should not have used 3.06
chris_n will duplicate this entry if it's needed to port this patch onto master.

I renumber the version to 3.07

I also have found in my testings that there is a problem if this DBrev is run twice (once in 3.6 and once in 3.8)
All patrons that are temporarily suspended (ie: have a date in debarred) will become suspended forever
The test was just made on debarred<>0, it's OK if we come from a 3.4, as debarred is a tinyint used as a boolean.
But if we already have a date, it won't do what we want.
I switched to a =1 instead of <>0, that fixes the problem

installer/data/mysql/updatedatabase.pl

index 9ae0060..e901a58 100755 (executable)
@@ -4551,9 +4551,9 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
     SetVersion ($DBversion);
 }
 
-$DBversion = "3.06.00.001";
+$DBversion = "3.07.00.001";
 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
-    my $borrowers = $dbh->selectcol_arrayref( "SELECT borrowernumber from borrowers where debarred <>0;", { Columns => [1] } );
+    my $borrowers = $dbh->selectcol_arrayref( "SELECT borrowernumber from borrowers where debarred =1;", { Columns => [1] } );
     $dbh->do("ALTER TABLE borrowers MODIFY debarred DATE DEFAULT NULL;");
     $dbh->do( "UPDATE borrowers set debarred='9999-12-31' where borrowernumber IN (" . join( ",", @$borrowers ) . ");" ) if ($borrowers and scalar(@$borrowers)>0);
     $dbh->do("ALTER TABLE borrowers ADD COLUMN debarredcomment VARCHAR(255) DEFAULT NULL AFTER debarred;");
@@ -4564,7 +4564,7 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
     SetVersion($DBversion);
 }
 
-$DBversion = "3.06.00.002";
+$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)";