From 48f9692edd4e6f6095df6471d41cc8bd8c1a1785 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 8 Oct 2020 14:14:33 +0000 Subject: [PATCH] Bug 13535: DBRev 20.06.00.046 Signed-off-by: Jonathan Druart --- Koha.pm | 2 +- .../atomicupdate/bug_13535_alert_constraint.perl | 16 ---------------- installer/data/mysql/updatedatabase.pl | 16 ++++++++++++++++ 3 files changed, 17 insertions(+), 17 deletions(-) delete mode 100644 installer/data/mysql/atomicupdate/bug_13535_alert_constraint.perl diff --git a/Koha.pm b/Koha.pm index 9fdccf002a..8a44e348e2 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 = "20.06.00.045"; +$VERSION = "20.06.00.046"; sub version { return $VERSION; diff --git a/installer/data/mysql/atomicupdate/bug_13535_alert_constraint.perl b/installer/data/mysql/atomicupdate/bug_13535_alert_constraint.perl deleted file mode 100644 index 2f837e2594..0000000000 --- a/installer/data/mysql/atomicupdate/bug_13535_alert_constraint.perl +++ /dev/null @@ -1,16 +0,0 @@ -$DBversion = 'XXX'; # will be replaced by the RM -if( CheckVersion( $DBversion ) ) { - unless ( foreign_key_exists( 'alert', 'alert_ibfk_1' ) ) { - $dbh->do(q| - DELETE a FROM alert a - LEFT JOIN borrowers b ON a.borrowernumber=b.borrowernumber - WHERE b.borrowernumber IS NULL - |); - $dbh->do( - qq{ - ALTER TABLE alert ADD CONSTRAINT alert_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON UPDATE CASCADE ON DELETE CASCADE - } - ); - } - NewVersion( $DBversion, 13535, "Add FK constraint on borrowernumber to alert table"); -} diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index cecc146a52..4464495575 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -22953,6 +22953,22 @@ if( CheckVersion( $DBversion ) ) { NewVersion( $DBversion, 22417, "Add new table background_jobs"); } +$DBversion = '20.06.00.046'; +if( CheckVersion( $DBversion ) ) { + unless ( foreign_key_exists( 'alert', 'alert_ibfk_1' ) ) { + $dbh->do(q| + DELETE a FROM alert a + LEFT JOIN borrowers b ON a.borrowernumber=b.borrowernumber + WHERE b.borrowernumber IS NULL + |); + $dbh->do(q| + ALTER TABLE alert + ADD CONSTRAINT alert_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON UPDATE CASCADE ON DELETE CASCADE + |); + } + NewVersion( $DBversion, 13535, "Add FK constraint on borrowernumber to alert table" ); +} + # SEE bug 13068 # if there is anything in the atomicupdate, read and execute it. my $update_dir = C4::Context->config('intranetdir') . '/installer/data/mysql/atomicupdate/'; -- 2.39.5