Bug 18982: Remove data in the correct order

To respect FK

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
(cherry picked from commit 6cb3abcbd9)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit 806357a8fc)
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
This commit is contained in:
Jonathan Druart 2017-07-26 13:50:14 -03:00 committed by Katrin Fischer
parent 87db7d92ac
commit cbbb54fd9a
1 changed files with 5 additions and 6 deletions

View File

@ -222,17 +222,16 @@ sub fill_form {
sub cleanup {
my $dbh = C4::Context->dbh;
$dbh->do(q|DELETE FROM borrowers WHERE userid = ?|, {}, $sample_data->{patron}{userid});
$dbh->do(q|DELETE FROM categories WHERE categorycode = ?|, {}, $sample_data->{category}{categorycode});
for my $i ( 1 .. $number_of_biblios_to_insert ) {
$dbh->do(qq|DELETE FROM biblio WHERE title = "test biblio $i"|);
};
$dbh->do(q|DELETE FROM issues where borrowernumber=?|, {}, $borrowernumber);
$dbh->do(q|DELETE FROM old_issues where borrowernumber=?|, {}, $borrowernumber);
for my $i ( 1 .. $number_of_biblios_to_insert ) {
$dbh->do(qq|DELETE items, biblio FROM biblio INNER JOIN items ON biblio.biblionumber = items.biblionumber WHERE biblio.title = "test biblio$i"|);
};
$dbh->do(q|DELETE FROM borrowers WHERE userid = ?|, {}, $sample_data->{patron}{userid});
$dbh->do(q|DELETE FROM categories WHERE categorycode = ?|, {}, $sample_data->{category}{categorycode});
for my $i ( 1 .. $number_of_biblios_to_insert ) {
$dbh->do(qq|DELETE FROM biblio WHERE title = "test biblio $i"|);
};
$dbh->do(q|DELETE FROM itemtypes WHERE itemtype=?|, undef, $sample_data->{itemtype}{itemtype});
$dbh->do(q|DELETE FROM issuingrules WHERE categorycode=? AND itemtype=? AND branchcode=?|, undef, $sample_data->{issuingrule}{categorycode}, $sample_data->{issuingrule}{itemtype}, $sample_data->{issuingrule}{branchcode});
}