From e7eac39e96a239d9f678931c6c12b80742454120 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 3 May 2016 15:04:20 +0000 Subject: [PATCH] Bug 16170 - DBRev 3.23.00.061 Signed-off-by: Kyle M Hall --- Koha.pm | 2 +- .../data/mysql/atomicupdate/16170_dbrev.perl | 29 ------------------- installer/data/mysql/updatedatabase.pl | 20 +++++++++++++ 3 files changed, 21 insertions(+), 30 deletions(-) delete mode 100644 installer/data/mysql/atomicupdate/16170_dbrev.perl diff --git a/Koha.pm b/Koha.pm index 0cd447fc22..bbb9ccf9b3 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 = "3.23.00.060"; +$VERSION = "3.23.00.061"; sub version { return $VERSION; diff --git a/installer/data/mysql/atomicupdate/16170_dbrev.perl b/installer/data/mysql/atomicupdate/16170_dbrev.perl deleted file mode 100644 index 542dd105ad..0000000000 --- a/installer/data/mysql/atomicupdate/16170_dbrev.perl +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/perl - -use C4::Context; - -my $dbh = C4::Context->dbh; -my $DBversion = "XXX"; - -# RM: Copy/paste from here, and uncomment - -#if ( CheckVersion($DBversion) ) { - # this should normally not be needed, but just in case - my ( $cnt ) = $dbh->selectrow_array( q| -SELECT COUNT(*) FROM items it -LEFT JOIN biblio bi ON bi.biblionumber=it.biblionumber -LEFT JOIN biblioitems bii USING (biblioitemnumber) -WHERE bi.biblionumber IS NULL - |); - if( $cnt ) { - print "WARNING: You have corrupted data in your items table!! The table contains $cnt references to biblio records that do not exist.\nPlease correct your data IMMEDIATELY after this upgrade and manually add the foreign key constraint for biblionumber in the items table.\n"; - } else { - # now add FK - $dbh->do( q| -ALTER TABLE items -ADD FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE - |); - print "Upgrade to $DBversion done (Bug 1xxxx - Add FK for biblionumber in items)\n"; - } - #SetVersion($DBversion); -#} diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 5bbde10c44..22576d4c10 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -12546,6 +12546,26 @@ if ( CheckVersion($DBversion) ) { SetVersion($DBversion); } +$DBversion = "3.23.00.061"; +if ( CheckVersion($DBversion) ) { + my ( $cnt ) = $dbh->selectrow_array( q| + SELECT COUNT(*) FROM items it + LEFT JOIN biblio bi ON bi.biblionumber=it.biblionumber + LEFT JOIN biblioitems bii USING (biblioitemnumber) + WHERE bi.biblionumber IS NULL + |); + if( $cnt ) { + print "WARNING: You have corrupted data in your items table!! The table contains $cnt references to biblio records that do not exist.\nPlease correct your data IMMEDIATELY after this upgrade and manually add the foreign key constraint for biblionumber in the items table.\n"; + } else { + # now add FK + $dbh->do( q| + ALTER TABLE items + ADD FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE + |); + print "Upgrade to $DBversion done (Bug 16170 - Add FK for biblionumber in items)\n"; + } + SetVersion($DBversion); +} # DEVELOPER PROCESS, search for anything to execute in the db_update directory # SEE bug 13068 -- 2.39.5