Bug 16354

Summary: Fix FK constraints for edifact_messages table
Product: Koha Reporter: Kyle M Hall <kyle>
Component: Architecture, internals, and plumbingAssignee: Kyle M Hall <kyle>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: bgkriegel, brendan, julian.maurice, katrin.fischer
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=16361
Change sponsored?: --- Patch complexity: Medium patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on: 15630    
Bug Blocks:    
Attachments: Bug 16354 - TestBuilder.t fails due to key constraints
[SIGNED-OFF] Bug 16354 - TestBuilder.t fails due to key constraints
[PASSED QA] Bug 16354 - TestBuilder.t fails due to key constraints

Description Kyle M Hall 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 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