[Koha] Wipe Koha database (just auth and biblio records)

Tomas Cohen Arazi tomascohen at gmail.com
Wed Jun 4 10:18:06 NZST 2014


Pablo, it's about relational integrity: if you turn foreign keys constrains
off, then OF COURSE you'll be able to delete whatever you want, and end up
with an inconsistent database.

As Robin pointed, using DELETE FROM, instead, will raise the ERRORS YOU
NEED TO BE AWARE OF, so you can acknowledge them, and make sure the db is
consistent. I.e. it will force you to delete linked data BEFORE you delete
the referenced one.

Regards
To+
El 03/06/2014 12:22, "Pablo Bianchi" <pablo.bianchi at gmail.com> escribió:

> Hi Robin!
>
> So you agree with me that Appendix F ("Resetting the Koha Database") of
> current (v3.16) manual is wrong?
>
> 2014-06-02 20:21 GMT-03:00 Robin Sheat <robin at catalyst.net.nz>:
>
> > Pablo Bianchi schreef op ma 02-06-2014 om 14:33 [-0300]:
> > > Am I right? This could be risky, having side effects?
> >
> > This could have nasty side-effects.
> >
> > By turning off the
> > ​​
> > constraint checks, you're not going to have any
> > messages telling you reasons why you shouldn't do what you're doing. For
> > example, circulation history, serial subscriptions, reserves, and
> > anything else that links with biblios and/or items aren't going to be
> > cleared. This means that you'll have entries in them pointing to things
> > that don't exist.
> >
>
> Problems that we can avoid just with​ *DELETE FROM biblio*?
>
>
> > Some better solutions might be to:
> >       * Do 'DELETE FROM table;' and then reset the auto numbering back
> >         to 1, something like 'ALTER TABLE table AUTO INCREMENT=1;'
> >         This'll ensure that things that should be deleted via
> >         constraints will be, or it won't let you do it. Also ensure that
> >         things that aren't constraint-linked are deleted (I think
> >         old_issues is one of these.)
> >
>
> ​​Despite the autoincrement issue, the *DELETE FROM biblio* way wasn't
> working for me. Now I'm not being able to reproduce the error, but I
> remember was very similar than with truncate, about *foreign key
> constraint*
> *.*
>
> I wonder why with -d option of bulkmarcimport.pl I had similar problems
> than with TRUNCATE, throw to stderr something like:
>
> *#1701 - Cannot truncate a table referenced in a foreign key constraint
> > (`koha_MyInstance`.`aqorders`, CONSTRAINT `aqorders_ibfk_2` FOREIGN KEY
> > (`biblionumber`) REFERENCES `koha_MyInstance`.`biblio` (`biblionumber`))*
> >
>
> What we can expect just taking a look to the source code:
>
> *if ($delete) {*
> *  if ($biblios){*
> *    print "deleting biblios\n";*
> *    $dbh->do("truncate biblio");*
> *     $dbh->do("truncate biblioitems");*
> *    $dbh->do("truncate items");*
> *  } else {*
> *    print "deleting authorities\n";*
> *    $dbh->do("truncate auth_header");*
> *  }*
> *   $dbh->do("truncate zebraqueue");*
> *}*​
>
> ​If this way is the right one, considering constraint checks, I can't see
> why we can't use it. Perhaps we can set up something differently in
> my.cnf...
>
>
> ​Regards,
> Pablo
> _______________________________________________
> Koha mailing list  http://koha-community.org
> Koha at lists.katipo.co.nz
> http://lists.katipo.co.nz/mailman/listinfo/koha
>


More information about the Koha mailing list