From d9ef08365fc0742b5b11b2220b60d812317ec13d Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 12 Jul 2021 13:45:17 +0000 Subject: [PATCH] Bug 14237: DBRev 21.06.00.006 Signed-off-by: Jonathan Druart --- Koha.pm | 2 +- ...-add_course_items.biblionumber_column.perl | 20 ------------------ installer/data/mysql/updatedatabase.pl | 21 +++++++++++++++++++ 3 files changed, 22 insertions(+), 21 deletions(-) delete mode 100644 installer/data/mysql/atomicupdate/bug_14237-add_course_items.biblionumber_column.perl diff --git a/Koha.pm b/Koha.pm index b3c28b100b..65ad2a34ba 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 = "21.06.00.005"; +$VERSION = "21.06.00.006"; sub version { return $VERSION; diff --git a/installer/data/mysql/atomicupdate/bug_14237-add_course_items.biblionumber_column.perl b/installer/data/mysql/atomicupdate/bug_14237-add_course_items.biblionumber_column.perl deleted file mode 100644 index a6e75bfe70..0000000000 --- a/installer/data/mysql/atomicupdate/bug_14237-add_course_items.biblionumber_column.perl +++ /dev/null @@ -1,20 +0,0 @@ -$DBversion = 'XXX'; -if( CheckVersion( $DBversion ) ){ - unless( column_exists( 'course_items', 'biblionumber') ) { - $dbh->do(q{ ALTER TABLE course_items ADD `biblionumber` int(11) AFTER `itemnumber` }); - - $dbh->do(q{ - UPDATE course_items - LEFT JOIN items ON items.itemnumber=course_items.itemnumber - SET course_items.biblionumber=items.biblionumber - WHERE items.itemnumber IS NOT NULL - }); - - $dbh->do(q{ ALTER TABLE course_items MODIFY COLUMN `biblionumber` INT(11) NOT NULL }); - - $dbh->do(q{ ALTER TABLE course_items ADD CONSTRAINT `fk_course_items_biblionumber` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE }); - $dbh->do(q{ ALTER TABLE course_items CHANGE `itemnumber` `itemnumber` int(11) DEFAULT NULL }); - } - - NewVersion( $DBversion, 14237, ["Add course_items.biblionumber column", "Add fk_course_items_biblionumber constraint", "Change course_items.itemnumber to allow NULL values"] ); -} diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index d31ec08766..cc3d5ecf9d 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -24373,6 +24373,27 @@ if( CheckVersion( $DBversion ) ) { NewVersion( $DBversion, 26205, "Add new system preference NewsLog to log news changes"); } +$DBversion = '21.06.00.006'; +if( CheckVersion( $DBversion ) ){ + unless( column_exists( 'course_items', 'biblionumber') ) { + $dbh->do(q{ ALTER TABLE course_items ADD `biblionumber` int(11) AFTER `itemnumber` }); + + $dbh->do(q{ + UPDATE course_items + LEFT JOIN items ON items.itemnumber=course_items.itemnumber + SET course_items.biblionumber=items.biblionumber + WHERE items.itemnumber IS NOT NULL + }); + + $dbh->do(q{ ALTER TABLE course_items MODIFY COLUMN `biblionumber` INT(11) NOT NULL }); + + $dbh->do(q{ ALTER TABLE course_items ADD CONSTRAINT `fk_course_items_biblionumber` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE }); + $dbh->do(q{ ALTER TABLE course_items CHANGE `itemnumber` `itemnumber` int(11) DEFAULT NULL }); + } + + NewVersion( $DBversion, 14237, ["Add course_items.biblionumber column", "Add fk_course_items_biblionumber constraint", "Change course_items.itemnumber to allow NULL values"] ); +} + # 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