From 51fa4a3f6ae3667772495271f68822d3416be5fb Mon Sep 17 00:00:00 2001 From: John Soros Date: Wed, 24 Jun 2009 15:03:30 +0200 Subject: [PATCH] Chenge database structure to not delete an order line when biblio gets deleted --- acqui/basket.pl | 12 ++++++++---- installer/data/mysql/kohastructure.sql | 2 +- installer/data/mysql/updatedatabase.pl | 9 +++++++++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/acqui/basket.pl b/acqui/basket.pl index c8142b31f2..07aec1d4ca 100755 --- a/acqui/basket.pl +++ b/acqui/basket.pl @@ -239,10 +239,14 @@ if ( $op eq 'delete_confirm' ) { $line{$key} .= '??'; } } - my $volume = $results[$i]->{'volume'}; - my $seriestitle = $results[$i]->{'seriestitle'}; - $line{'title'} .= " / $seriestitle" if $seriestitle; - $line{'title'} .= " / $volume" if $volume; + if ($line{'title'}){ + my $volume = $results[$i]->{'volume'}; + my $seriestitle = $results[$i]->{'seriestitle'}; + $line{'title'} .= " / $seriestitle" if $seriestitle; + $line{'title'} .= " / $volume" if $volume; + } else { + $line{'title'} = "Deleted bibliographic notice, can't find title."; + } push @books_loop, \%line; } diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index a4b1e2c35d..409fa67196 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -312,7 +312,7 @@ CREATE TABLE `aqorders` ( KEY `basketno` (`basketno`), KEY `biblionumber` (`biblionumber`), CONSTRAINT `aqorders_ibfk_1` FOREIGN KEY (`basketno`) REFERENCES `aqbasket` (`basketno`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `aqorders_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE SET NULL + CONSTRAINT `aqorders_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE, ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 053cecf74c..528628dcf9 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -2993,6 +2993,15 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } +$DBversion = "3.00.99.023"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do("ALTER TABLE `aqorders` drop foreign key `aqorders_ibfk_2`"); + $dbh->do("ALTER TABLE `aqorders` drop key `biblionumber`"); + $dbh->do("ALTER TABLE `aqorders` ADD foreign key (biblionumber) REFERENCES biblio(`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE;"); + print "Upgrade to $DBversion done adding display column to aqbudgets_planning\n"; + SetVersion ($DBversion); +} + =item DropAllForeignKeys($table) Drop all foreign keys of the table $table -- 2.39.5