View | Details | Raw Unified | Return to bug 22008
Collapse All | Expand All

(-)a/installer/data/mysql/atomicupdate/bug_22008.perl (-2 / +2 lines)
Lines 3-10 if( CheckVersion( $DBversion ) ) { Link Here
3
3
4
    # Add constraint for manager_id
4
    # Add constraint for manager_id
5
    unless( foreign_key_exists( 'accountlines', 'accountlines_ibfk_borrowers_2' ) ) {
5
    unless( foreign_key_exists( 'accountlines', 'accountlines_ibfk_borrowers_2' ) ) {
6
        $dbh->do("ALTER TABLE accountlines CHANGE COLUMN manager_id manager_id INT(11) NULL DEFAULT NULL;");
6
        $dbh->do("ALTER TABLE accountlines CHANGE COLUMN manager_id manager_id INT(11) NULL DEFAULT NULL");
7
        $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;
7
        $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");
8
        $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");
8
        $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");
9
    }
9
    }
10
10
(-)a/t/db_dependent/Koha/Account/Lines.t (-2 / +2 lines)
Lines 284-290 subtest 'Keep account info when related patron, staff or item is deleted' => sub Link Here
284
    my $item = $builder->build_object({ class => 'Koha::Items' });
284
    my $item = $builder->build_object({ class => 'Koha::Items' });
285
    my $issue = $builder->build_object(
285
    my $issue = $builder->build_object(
286
        {
286
        {
287
            class => 'Koha::Checkout',
287
            class => 'Koha::Checkouts',
288
            value => { itemnumber => $item->itemnumber }
288
            value => { itemnumber => $item->itemnumber }
289
        }
289
        }
290
    );
290
    );
Lines 297-302 subtest 'Keep account info when related patron, staff or item is deleted' => sub Link Here
297
        amount         => 10,
297
        amount         => 10,
298
    })->store;
298
    })->store;
299
299
300
    $issue->delete;
300
    $item->delete;
301
    $item->delete;
301
    $line = $line->get_from_storage;
302
    $line = $line->get_from_storage;
302
    is( $line->itemnumber, undef, "The account line should not be deleted when the related item is delete");
303
    is( $line->itemnumber, undef, "The account line should not be deleted when the related item is delete");
303
- 

Return to bug 22008