@@ -, +, @@ --- installer/data/mysql/atomicupdate/bug_22008.perl | 4 ++-- t/db_dependent/Koha/Account/Lines.t | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) --- a/installer/data/mysql/atomicupdate/bug_22008.perl +++ a/installer/data/mysql/atomicupdate/bug_22008.perl @@ -3,8 +3,8 @@ if( CheckVersion( $DBversion ) ) { # Add constraint for manager_id unless( foreign_key_exists( 'accountlines', 'accountlines_ibfk_borrowers_2' ) ) { - $dbh->do("ALTER TABLE accountlines CHANGE COLUMN manager_id manager_id INT(11) NULL DEFAULT NULL;"); - $dbh->do("UPDATE accountlines a LEFT JOIN borrowers b ON ( a.manager_id = b.borrowernumber) SET a.manager_id = NULL WHERE b.borrowernumber IS NULL; + $dbh->do("ALTER TABLE accountlines CHANGE COLUMN manager_id manager_id INT(11) NULL DEFAULT NULL"); + $dbh->do("UPDATE accountlines a LEFT JOIN borrowers b ON ( a.manager_id = b.borrowernumber) SET a.manager_id = NULL WHERE b.borrowernumber IS NULL"); $dbh->do("ALTER TABLE accountlines ADD CONSTRAINT `accountlines_ibfk_borrowers_2` FOREIGN KEY (`manager_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE"); } --- a/t/db_dependent/Koha/Account/Lines.t +++ a/t/db_dependent/Koha/Account/Lines.t @@ -285,7 +285,7 @@ subtest 'Keep account info when related patron, staff or item is deleted' => sub my $item = $builder->build_object({ class => 'Koha::Items' }); my $issue = $builder->build_object( { - class => 'Koha::Checkout', + class => 'Koha::Checkouts', value => { itemnumber => $item->itemnumber } } ); @@ -298,6 +298,7 @@ subtest 'Keep account info when related patron, staff or item is deleted' => sub amount => 10, })->store; + $issue->delete; $item->delete; $line = $line->get_from_storage; is( $line->itemnumber, undef, "The account line should not be deleted when the related item is delete"); --