Koha/installer/data/mysql/db_revs/210600006.pl
Jonathan Druart 8b0a44dcb5 Bug 25078: Explicitely return from DB revs to avoid warnings
% perl -wc installer/data/mysql/atomicupdate/skeleton.pl
Useless use of anonymous hash ({}) in void context at installer/data/mysql/atomicupdate/skeleton.pl

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2021-08-18 12:59:35 +02:00

31 lines
1.3 KiB
Perl
Executable file

use Modern::Perl;
return {
bug_number => "14237",
description => "Add individual bibliographic records to course reserves",
up => sub {
my ($args) = @_;
my $dbh = $args->{dbh};
my $out = $args->{out};
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 });
say $out "Add course_items.biblionumber column";
say $out "Add fk_course_items_biblionumber constraint";
say $out "Change course_items.itemnumber to allow NULL values";
}
},
}