From 4ebc3a2bcae527c4099b806dba5bded92ab0fd68 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 3 May 2016 15:04:20 +0000 Subject: [PATCH] Bug 16170: Update DB rev (3.22.06.003) Signed-off-by: Julian Maurice --- Koha.pm | 2 +- .../data/mysql/atomicupdate/16170_dbrev.perl | 29 ------------------- installer/data/mysql/updatedatabase.pl | 21 ++++++++++++++ 3 files changed, 22 insertions(+), 30 deletions(-) delete mode 100644 installer/data/mysql/atomicupdate/16170_dbrev.perl diff --git a/Koha.pm b/Koha.pm index 508891a2a6..27f93cb896 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.22.06.002"; +$VERSION = "3.22.06.003"; 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 a80ee3d34f..87d2e14f2c 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -11583,6 +11583,27 @@ if ( CheckVersion($DBversion) ) { SetVersion($DBversion); } +$DBversion = "3.22.06.003"; +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