Bug 16354 - Fix FK constraints for edifact_messages table
Summary: Fix FK constraints for edifact_messages table
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Kyle M Hall (khall)
QA Contact: Testopia
URL:
Keywords:
Depends on: 15630
Blocks:
  Show dependency treegraph
 
Reported: 2016-04-26 15:38 UTC by Kyle M Hall (khall)
Modified: 2016-12-05 21:22 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Medium patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 16354 - TestBuilder.t fails due to key constraints (2.43 KB, patch)
2016-04-26 15:46 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 16354 - TestBuilder.t fails due to key constraints (2.55 KB, patch)
2016-04-26 17:10 UTC, Bernardo Gonzalez Kriegel
Details | Diff | Splinter Review
[PASSED QA] Bug 16354 - TestBuilder.t fails due to key constraints (2.60 KB, patch)
2016-04-26 21:47 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Kyle M Hall (khall) 2016-04-26 15:38:09 UTC
From Bug 15630:
t/db_dependent/TestBuilder.t .. 3/41 DBD::mysql::st execute failed: Cannot delete or update a parent row: a foreign key constraint fails (`koha_empty`.`edifact_messages`, CONSTRAINT `emfk_basketno` FOREIGN KEY (`basketno`) REFERENCES `aqbasket` (`basketno`)) [for Statement "DELETE FROM `aqbasket` WHERE ( `basketno` = ? )" with ParamValues: 0='13'] at /usr/share/perl5/DBIx/Class/Storage/DBI.pm line 1834.

the foreign keys don't not have a ON * CASCADE clause.
Comment 1 Kyle M Hall (khall) 2016-04-26 15:46:44 UTC Comment hidden (obsolete)
Comment 2 Bernardo Gonzalez Kriegel 2016-04-26 17:10:09 UTC Comment hidden (obsolete)
Comment 3 Katrin Fischer 2016-04-26 21:47:31 UTC
Created attachment 50763 [details] [review]
[PASSED QA] Bug 16354 - TestBuilder.t fails due to key constraints

Test Plan:
1) prove t/db_dependent/TestBuilder.t
2) Note failure
3) Apply this patch
4) prove t/db_dependent/TestBuilder.t
5) Tests should now pass!

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Failure noted and corrected.
No errors

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 4 Brendan Gallagher 2016-04-26 23:14:54 UTC
Pushed to Master - Should be in the May 2016 Release.  Thanks!
Comment 5 Bernardo Gonzalez Kriegel 2016-04-27 02:05:45 UTC
(In reply to Brendan Gallagher from comment #4)
> Pushed to Master - Should be in the May 2016 Release.  Thanks!

(In reply to Brendan Gallagher from comment #4)
> Pushed to Master - Should be in the May 2016 Release.  Thanks!

Hi Brendan,
I have a failure in updatedatabase here,
perhaps each sentence neeeds it's own $dbh->do

$dbh->do(q{
        ALTER TABLE edifact_messages
        DROP FOREIGN KEY emfk_vendor,
        DROP FOREIGN KEY emfk_edi_acct,
        DROP FOREIGN KEY emfk_basketno;
        });

$dbh->do(q{
        ALTER TABLE edifact_messages
        ADD CONSTRAINT emfk_vendor FOREIGN KEY ( vendor_id ) REFERENCES aqbooksellers ( id ) ON DELETE CASCADE ON UPDATE CASCADE,
        ADD CONSTRAINT emfk_edi_acct FOREIGN KEY ( edi_acct ) REFERENCES vendor_edi_accounts ( id ) ON DELETE CASCADE ON UPDATE CASCADE,
        ADD CONSTRAINT emfk_basketno FOREIGN KEY ( basketno ) REFERENCES aqbasket ( basketno ) ON DELETE CASCADE ON UPDATE CASCADE;
        });
Comment 6 Julian Maurice 2016-05-09 08:13:17 UTC
Not needed in stable version, status changed to RESOLVED