Bug 26997: Fix upgrade process under MySQL 8
If you are coming from an old version of Koha, you may face an upgrade error for the SQL query using 0000-00-00. The idea was to fix it, but actually the DBMS will raise an error (not blocking the upgrade process however). We can hide them to not cause confusion Errors are like: DBD::mysql::db do failed: Incorrect date value: '0000-00-00' for column 'suggesteddate' at row 1 [for Statement "UPDATE suggestions SET suggesteddate = '1970-01-01' WHERE suggesteddate = '0000-00-00';"] at /kohadevbox/koha/installer/data/mysql/updatedatabase.pl line 23312. Test plan: Checkout an old version of Koha (3.20, not older) Insert a dump, install Koha Checkout a recent version of Koha, apply the patch (or use master) Execute the upgrade process You should not see the errors Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> (cherry picked from commit3c087bc216) Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com> (cherry picked from commitda58f3e2c5) Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> (cherry picked from commitc720acc3c9) Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
This commit is contained in:
parent
5bc7e65a04
commit
7e3bf82654
|
|
@ -10639,11 +10639,14 @@ if ( CheckVersion($DBversion) ) {
|
|||
|
||||
$DBversion = "3.21.00.009";
|
||||
if ( CheckVersion($DBversion) ) {
|
||||
$dbh->do(q|
|
||||
UPDATE aqorders SET orderstatus='cancelled'
|
||||
WHERE (datecancellationprinted IS NOT NULL OR
|
||||
datecancellationprinted<>'0000-00-00');
|
||||
|);
|
||||
eval {
|
||||
local $dbh->{PrintError} = 0;
|
||||
$dbh->do(q|
|
||||
UPDATE aqorders SET orderstatus='cancelled'
|
||||
WHERE (datecancellationprinted IS NOT NULL OR
|
||||
datecancellationprinted<>'0000-00-00');
|
||||
|);
|
||||
};
|
||||
print "Upgrade to $DBversion done (Bug 13993: Correct orderstatus for transferred orders)\n";
|
||||
SetVersion($DBversion);
|
||||
}
|
||||
|
|
@ -10874,18 +10877,22 @@ if ( CheckVersion($DBversion) ) {
|
|||
|
||||
$DBversion = "3.21.00.023";
|
||||
if ( CheckVersion($DBversion) ) {
|
||||
$dbh->do(q{
|
||||
UPDATE borrowers SET debarred=NULL WHERE debarred='0000-00-00'
|
||||
});
|
||||
$dbh->do(q{
|
||||
UPDATE borrowers SET dateexpiry=NULL where dateexpiry='0000-00-00'
|
||||
});
|
||||
$dbh->do(q{
|
||||
UPDATE borrowers SET dateofbirth=NULL where dateofbirth='0000-00-00'
|
||||
});
|
||||
$dbh->do(q{
|
||||
UPDATE borrowers SET dateenrolled=NULL where dateenrolled='0000-00-00'
|
||||
});
|
||||
eval {
|
||||
local $dbh->{PrintError} = 0;
|
||||
$dbh->do(q{
|
||||
UPDATE borrowers SET debarred=NULL WHERE debarred='0000-00-00'
|
||||
});
|
||||
$dbh->do(q{
|
||||
UPDATE borrowers SET dateexpiry=NULL where dateexpiry='0000-00-00'
|
||||
});
|
||||
$dbh->do(q{
|
||||
UPDATE borrowers SET dateofbirth=NULL where dateofbirth='0000-00-00'
|
||||
});
|
||||
$dbh->do(q{
|
||||
UPDATE borrowers SET dateenrolled=NULL where dateenrolled='0000-00-00'
|
||||
});
|
||||
};
|
||||
|
||||
print "Upgrade to $DBversion done (Bug 14717: Prevent 0000-00-00 dates in patron data)\n";
|
||||
SetVersion($DBversion);
|
||||
}
|
||||
|
|
@ -17633,15 +17640,18 @@ $DBversion = '18.12.00.024';
|
|||
if ( CheckVersion($DBversion) ) {
|
||||
|
||||
# Fixup any pre-existing bad suggestedby, manageddate, accepteddate dates
|
||||
$dbh->do(
|
||||
"UPDATE suggestions SET suggesteddate = '1970-01-01' WHERE suggesteddate = '0000-00-00';"
|
||||
);
|
||||
$dbh->do(
|
||||
"UPDATE suggestions SET manageddate = '1970-01-01' WHERE manageddate = '0000-00-00';"
|
||||
);
|
||||
$dbh->do(
|
||||
"UPDATE suggestions SET accepteddate = '1970-01-01' WHERE accepteddate = '0000-00-00';"
|
||||
);
|
||||
eval {
|
||||
local $dbh->{PrintError} = 0;
|
||||
$dbh->do(
|
||||
"UPDATE suggestions SET suggesteddate = '1970-01-01' WHERE suggesteddate = '0000-00-00';"
|
||||
);
|
||||
$dbh->do(
|
||||
"UPDATE suggestions SET manageddate = '1970-01-01' WHERE manageddate = '0000-00-00';"
|
||||
);
|
||||
$dbh->do(
|
||||
"UPDATE suggestions SET accepteddate = '1970-01-01' WHERE accepteddate = '0000-00-00';"
|
||||
);
|
||||
};
|
||||
|
||||
# Add constraint for suggestedby
|
||||
unless ( foreign_key_exists( 'suggestions', 'suggestions_ibfk_suggestedby' ) )
|
||||
|
|
|
|||
Loading…
Reference in New Issue