From 336c54860531253d860165dc9a6d406892b1600a Mon Sep 17 00:00:00 2001 From: Blou Date: Fri, 27 Jul 2018 11:41:16 -0400 Subject: [PATCH] Bug 21129: New ALTER IGNORE TABLE entries need correction in updatedatabase.pl Bug 17234 made an effort to remove the ALTER IGNORE from updatedatabase.pl so that it could work with Mysql 5.7. But new entries have since been added to it: Bug 12395 - 18.06.00.005 Bug 19524 - 18.06.00.006 Bug 13560 - 18.06.00.008 This is corrected using column_exists to validate the existence of the new columns before ALTER Signed-off-by: Jonathan Druart Signed-off-by: Josef Moravec Signed-off-by: Tomas Cohen Arazi --- installer/data/mysql/updatedatabase.pl | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 6e967b89bb..c4ca176865 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -16129,16 +16129,22 @@ if( CheckVersion( $DBversion ) ) { $DBversion = '18.06.00.005'; if( CheckVersion( $DBversion ) ) { - $dbh->do( "ALTER IGNORE TABLE aqorders ADD COLUMN created_by int(11) NULL DEFAULT NULL AFTER quantityreceived;" ); - $dbh->do( "ALTER IGNORE TABLE aqorders ADD CONSTRAINT aqorders_created_by FOREIGN KEY (created_by) REFERENCES borrowers (borrowernumber) ON DELETE SET NULL ON UPDATE CASCADE;" ); - $dbh->do( "UPDATE aqorders, aqbasket SET aqorders.created_by = aqbasket.authorisedby WHERE aqorders.basketno = aqbasket.basketno AND aqorders.created_by IS NULL;" ); + unless ( column_exists('aqorders', 'created') ) { + $dbh->do( "ALTER TABLE aqorders ADD COLUMN created_by int(11) NULL DEFAULT NULL AFTER quantityreceived;" ); + unless ( foreign_key_exists('aqorders', 'aqorders_created_by') ) { + $dbh->do( "ALTER TABLE aqorders ADD CONSTRAINT aqorders_created_by FOREIGN KEY (created_by) REFERENCES borrowers (borrowernumber) ON DELETE SET NULL ON UPDATE CASCADE;" ); + } + $dbh->do( "UPDATE aqorders, aqbasket SET aqorders.created_by = aqbasket.authorisedby WHERE aqorders.basketno = aqbasket.basketno AND aqorders.created_by IS NULL;" ); + } SetVersion( $DBversion ); print "Upgrade to $DBversion done (Bug 12395 - Save order line's creator)\n"; } $DBversion = '18.06.00.006'; if( CheckVersion( $DBversion ) ) { - $dbh->do( "ALTER IGNORE TABLE patron_lists ADD COLUMN shared tinyint(1) default 0 AFTER owner;" ); + unless ( column_exists('patron_lists', 'shared') ) { + $dbh->do( "ALTER TABLE patron_lists ADD COLUMN shared tinyint(1) default 0 AFTER owner;" ); + } SetVersion( $DBversion ); print "Upgrade to $DBversion done (Bug 19524 - Share patron lists between staff)\n"; } @@ -16157,7 +16163,7 @@ if( CheckVersion( $DBversion ) ) { $DBversion = '18.06.00.008'; if( CheckVersion( $DBversion ) ) { - $dbh->do( "ALTER IGNORE TABLE marc_modification_template_actions CHANGE action action ENUM('delete_field','add_field','update_field','move_field','copy_field','copy_and_replace_field')" ); + $dbh->do( "ALTER TABLE marc_modification_template_actions CHANGE action action ENUM('delete_field','add_field','update_field','move_field','copy_field','copy_and_replace_field')" ); SetVersion( $DBversion ); print "Upgrade to $DBversion done (Bug 13560 - need an add option in marc modification templates)\n"; }