Bugzilla – Attachment 113495 Details for
Bug 26997
Database Mysql Version 8.0.22 failed to Update During Upgrade
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26997: Fix upgrade process under MySQL 8
Bug-26997-Fix-upgrade-process-under-MySQL-8.patch (text/plain), 5.38 KB, created by
Jonathan Druart
on 2020-11-11 13:25:48 UTC
(
hide
)
Description:
Bug 26997: Fix upgrade process under MySQL 8
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-11-11 13:25:48 UTC
Size:
5.38 KB
patch
obsolete
>From dca6902934b14c45daeb84524d680fa8c3e73a82 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 11 Nov 2020 14:22:50 +0100 >Subject: [PATCH] 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 >--- > installer/data/mysql/updatedatabase.pl | 104 +++++++++++++------------ > 1 file changed, 54 insertions(+), 50 deletions(-) > >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 1d3f65ac6e..b02107133c 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -10635,11 +10635,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); > } >@@ -10870,18 +10873,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); > } >@@ -17629,15 +17636,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' ) ) >@@ -21685,32 +21695,26 @@ $DBversion = '19.12.00.076'; > if( CheckVersion( $DBversion ) ) { > my @warnings; > >- $dbh->do(q| >- UPDATE >- serial >- SET >- planneddate = NULL >- WHERE >- planneddate = '0000-00-00' >- |); >+ eval { >+ local $dbh->{PrintError} = 0; >+ $dbh->do(q| >+ UPDATE serial >+ SET planneddate = NULL >+ WHERE planneddate = '0000-00-00' >+ |); > >- $dbh->do(q| >- UPDATE >- serial >- SET >- publisheddate = NULL >- WHERE >- publisheddate = '0000-00-00' >- |); >+ $dbh->do(q| >+ UPDATE serial >+ SET publisheddate = NULL >+ WHERE publisheddate = '0000-00-00' >+ |); > >- $dbh->do(q| >- UPDATE >- serial >- SET >- claimdate = NULL >- WHERE >- claimdate = '0000-00-00' >- |); >+ $dbh->do(q| >+ UPDATE serial >+ SET claimdate = NULL >+ WHERE claimdate = '0000-00-00' >+ |); >+ }; > > $dbh->do(q| > ALTER TABLE serial >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 26997
:
113495
|
113600
|
114526
|
114527
|
117038
|
117178
|
117179
|
117180
|
117181
|
117428