From 7b94dfaa2d82d961d4a1e48a8c82f967f75779d5 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Mon, 25 Feb 2019 22:59:29 +0000 Subject: [PATCH] Bug: 13515 DBRev 18.05.09.001 Signed-off-by: Lucas Gass --- Koha.pm | 2 +- .../data/mysql/atomicupdate/bug_13515.perl | 20 ----------------- installer/data/mysql/updatedatabase.pl | 22 +++++++++++++++++++ 3 files changed, 23 insertions(+), 21 deletions(-) delete mode 100644 installer/data/mysql/atomicupdate/bug_13515.perl diff --git a/Koha.pm b/Koha.pm index 062969dca6..739faccf90 100644 --- a/Koha.pm +++ b/Koha.pm @@ -29,7 +29,7 @@ use vars qw{ $VERSION }; # - #4 : the developer version. The 4th number is the database subversion. # used by developers when the database changes. updatedatabase take care of the changes itself # and is automatically called by Auth.pm when needed. -$VERSION = "18.05.09.000"; +$VERSION = "18.05.09.001"; sub version { return $VERSION; diff --git a/installer/data/mysql/atomicupdate/bug_13515.perl b/installer/data/mysql/atomicupdate/bug_13515.perl deleted file mode 100644 index 7a97061fba..0000000000 --- a/installer/data/mysql/atomicupdate/bug_13515.perl +++ /dev/null @@ -1,20 +0,0 @@ -$DBversion = 'XXX'; # will be replaced by the RM -if( CheckVersion( $DBversion ) ) { - - unless( foreign_key_exists( 'messages', 'messages_borrowernumber' ) ) { - $dbh->do(q| - DELETE m FROM messages m - LEFT JOIN borrowers b ON m.borrowernumber=b.borrowernumber - WHERE b.borrowernumber IS NULL - |); - - $dbh->do(q| - ALTER TABLE messages - ADD CONSTRAINT messages_borrowernumber - FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE - |); - } - - SetVersion( $DBversion ); - print "Upgrade to $DBversion done (Bug 13515 - Add a FOREIGN KEY constaint on messages.borrowernumber)\n"; -} diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 4f4561d973..89ea80b617 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -16308,6 +16308,28 @@ if ( CheckVersion($DBversion) ) { SetVersion ($DBversion); } + +$DBversion = '18.05.09.001'; +if( CheckVersion( $DBversion ) ) { + + unless( foreign_key_exists( 'messages', 'messages_borrowernumber' ) ) { + $dbh->do(q| + DELETE m FROM messages m + LEFT JOIN borrowers b ON m.borrowernumber=b.borrowernumber + WHERE b.borrowernumber IS NULL + |); + + $dbh->do(q| + ALTER TABLE messages + ADD CONSTRAINT messages_borrowernumber + FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE + |); + } + + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 13515 - Add a FOREIGN KEY constaint on messages.borrowernumber)\n"; +} + # SEE bug 13068 # if there is anything in the atomicupdate, read and execute it. -- 2.39.5