Bugzilla – Attachment 33291 Details for
Bug 12555
The DelItem subroutine should be called on canceling a receipt
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12555: Add a FK on aqorders_items.itemnumber
Bug-12555-Add-a-FK-on-aqordersitemsitemnumber.patch (text/plain), 2.61 KB, created by
Jonathan Druart
on 2014-11-06 08:49:29 UTC
(
hide
)
Description:
Bug 12555: Add a FK on aqorders_items.itemnumber
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2014-11-06 08:49:29 UTC
Size:
2.61 KB
patch
obsolete
>From a395787002f07e39133b2ce49f8d1bd6919eff39 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Wed, 20 Aug 2014 12:02:56 +0200 >Subject: [PATCH] Bug 12555: Add a FK on aqorders_items.itemnumber > >The previous patch assumed that deleting an item will delete the entry >in aqorders_items. But the FK did not exist. > >Looking at the code, we never join aqorders_items and deleteditems, so I >think we can add this constraint. > >Before adding this constraint, we need to delete all entries in >aqorders_items if the item has already been deleted. >--- > installer/data/mysql/kohastructure.sql | 3 ++- > installer/data/mysql/updatedatabase.pl | 15 +++++++++++++++ > 2 files changed, 17 insertions(+), 1 deletion(-) > >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 865f930..22e897b 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -3074,7 +3074,8 @@ CREATE TABLE `aqorders_items` ( -- information on items entered in the acquisiti > `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this order item was last touched > PRIMARY KEY (`itemnumber`), > KEY `ordernumber` (`ordernumber`), >- CONSTRAINT aqorders_items_ibfk_1 FOREIGN KEY (ordernumber) REFERENCES aqorders (ordernumber) ON DELETE CASCADE ON UPDATE CASCADE >+ CONSTRAINT aqorders_items_ibfk_1 FOREIGN KEY (ordernumber) REFERENCES aqorders (ordernumber) ON DELETE CASCADE ON UPDATE CASCADE, >+ CONSTRAINT `aqorders_items_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE > ) ENGINE=InnoDB DEFAULT CHARSET=utf8; > > >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 078a9f3..f9079a6 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -8974,6 +8974,21 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { > SetVersion($DBversion); > } > >+$DBversion = '3.17.00.XXX'; >+if ( CheckVersion($DBversion) ) { >+ $dbh->do(q| >+ DELETE aqorders_items.* >+ FROM aqorders_items >+ LEFT JOIN items ON items.itemnumber=aqorders_items.itemnumber >+ WHERE items.itemnumber IS NULL >+ |); >+ $dbh->do(q| >+ ALTER TABLE aqorders_items ADD FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE >+ |); >+ print "Upgrade to $DBversion done (Bug 12555 - Add a foreign key on aqorders_items.itemnumber)\n"; >+ SetVersion($DBversion); >+} >+ > =head1 FUNCTIONS > > =head2 TableExists($table) >-- >2.1.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 12555
:
29752
|
30613
|
31008
|
33290
|
33291
|
34016
|
34017
|
34157
|
34158
|
34159