https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24658

--- Comment #10 from Nick Clemens <[email protected]> ---
(In reply to Jonathan Druart from comment #9)
> There is a FK on accountlines.itemnumber, and apparently it is there for a
> long time now.
> 
> Can you confirm that this constraint does not exist in your database?
> 
> "show create table accountlines;" will tell you if there is a CONSTRAINT  on
> items.itemnumber

The update that added this constraint:
if ( foreign_key_exists( 'accountlines', 'accountlines_ibfk_2' ) &&
!foreign_key_exists( 'accountlines', 'accountlines_ibfk_items' ) ) {
    $dbh->do("ALTER TABLE accountlines DROP FOREIGN KEY accountlines_ibfk_2");
    $dbh->do("ALTER TABLE accountlines ADD CONSTRAINT `accountlines_ibfk_items`
FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE SET NULL
ON UPDATE CASCADE");
}

It looks like if you don't have the original constraint you don't get the new
one, perhaps we could do:
if ( foreign_key_exists( 'accountlines', 'accountlines_ibfk_2' ) {
    $dbh->do("ALTER TABLE accountlines DROP FOREIGN KEY accountlines_ibfk_2");
}
unless( foreign_key_exists( 'accountlines', 'accountlines_ibfk_items' ) ){
    $dbh->do("ALTER TABLE accountlines ADD CONSTRAINT `accountlines_ibfk_items`
FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE SET NULL
ON UPDATE CASCADE");
}

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list
[email protected]
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to