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 285-291 subtest 'Keep account info when related patron, staff or item is deleted' => sub Link Here
285
    my $item = $builder->build_object({ class => 'Koha::Items' });
285
    my $item = $builder->build_object({ class => 'Koha::Items' });
286
    my $issue = $builder->build_object(
286
    my $issue = $builder->build_object(
287
        {
287
        {
288
            class => 'Koha::Checkout',
288
            class => 'Koha::Checkouts',
289
            value => { itemnumber => $item->itemnumber }
289
            value => { itemnumber => $item->itemnumber }
290
        }
290
        }
291
    );
291
    );
Lines 298-303 subtest 'Keep account info when related patron, staff or item is deleted' => sub Link Here
298
        amount         => 10,
298
        amount         => 10,
299
    })->store;
299
    })->store;
300
300
301
    $issue->delete;
301
    $item->delete;
302
    $item->delete;
302
    $line = $line->get_from_storage;
303
    $line = $line->get_from_storage;
303
    is( $line->itemnumber, undef, "The account line should not be deleted when the related item is delete");
304
    is( $line->itemnumber, undef, "The account line should not be deleted when the related item is delete");
304
- 

Return to bug 22008