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 <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Blou 2018-07-27 11:41:16 -04:00 committed by Tomas Cohen Arazi
parent ce96080f30
commit 336c548605

View file

@ -16129,16 +16129,22 @@ if( CheckVersion( $DBversion ) ) {
$DBversion = '18.06.00.005'; $DBversion = '18.06.00.005';
if( CheckVersion( $DBversion ) ) { if( CheckVersion( $DBversion ) ) {
$dbh->do( "ALTER IGNORE TABLE aqorders ADD COLUMN created_by int(11) NULL DEFAULT NULL AFTER quantityreceived;" ); unless ( column_exists('aqorders', 'created') ) {
$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( "ALTER TABLE aqorders ADD COLUMN created_by int(11) NULL DEFAULT NULL AFTER quantityreceived;" );
$dbh->do( "UPDATE aqorders, aqbasket SET aqorders.created_by = aqbasket.authorisedby WHERE aqorders.basketno = aqbasket.basketno AND aqorders.created_by IS NULL;" ); 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 ); SetVersion( $DBversion );
print "Upgrade to $DBversion done (Bug 12395 - Save order line's creator)\n"; print "Upgrade to $DBversion done (Bug 12395 - Save order line's creator)\n";
} }
$DBversion = '18.06.00.006'; $DBversion = '18.06.00.006';
if( CheckVersion( $DBversion ) ) { 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 ); SetVersion( $DBversion );
print "Upgrade to $DBversion done (Bug 19524 - Share patron lists between staff)\n"; 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'; $DBversion = '18.06.00.008';
if( CheckVersion( $DBversion ) ) { 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 ); SetVersion( $DBversion );
print "Upgrade to $DBversion done (Bug 13560 - need an add option in marc modification templates)\n"; print "Upgrade to $DBversion done (Bug 13560 - need an add option in marc modification templates)\n";
} }