Bugzilla – Attachment 65403 Details for
Bug 19016
Add a script to fix corrupted data
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19016: Update other values
Bug-19016-Update-other-values.patch (text/plain), 4.72 KB, created by
Jonathan Druart
on 2017-08-01 17:29:37 UTC
(
hide
)
Description:
Bug 19016: Update other values
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2017-08-01 17:29:37 UTC
Size:
4.72 KB
patch
obsolete
>From feb2a91c6d9ea77b0bf039a0e725651e2ccb0fb9 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 1 Aug 2017 14:14:24 -0300 >Subject: [PATCH] Bug 19016: Update other values > >Here we have a problem! >If we assign a new id to the different rows that cannot be moved >safetly, we need to modify the other tables that do not have a foreign >key (for historical or laziness reasons). > >For instance: >John is borrowernumber=42 and create a suggestion >(suggestion.suggestedby=42) >Jane is borrowernumber=42 in the deletedborrowers table. She created a >suggestion (same suggestedby value). > >John will get a new id and the suggestion.suggestedby will not be >replaced without this patch. But with this fix, the 2 suggestions will >be marked as suggested by him. >--- > misc/cronjobs/cleanup_database.pl | 32 ++++++++++++++++++++++++++++++++ > 1 file changed, 32 insertions(+) > >diff --git a/misc/cronjobs/cleanup_database.pl b/misc/cronjobs/cleanup_database.pl >index df3c4e99b9..f1e6324758 100755 >--- a/misc/cronjobs/cleanup_database.pl >+++ b/misc/cronjobs/cleanup_database.pl >@@ -507,6 +507,38 @@ sub FixCorruptedData { > print "Updating $table.$col_name=$old_id with new id $max\n"; > eval { > $sth_fix->execute( $max, $old_id ); >+ if ( $table eq 'issues' ) { >+ $dbh->do( q|UPDATE accountlines SET issue_id = ? WHERE issue_id = ?|, undef, $max, $old_id ); >+ } elsif ( $table eq 'borrowers' ) { >+ $dbh->do( q|UPDATE borrower_password_recovery SET borrowernumber = ? WHERE borrowernumber = ?|, undef, $max, $old_id ); >+ $dbh->do( q|UPDATE borrowers SET guarantorid = ? WHERE guarantorid= ?|, undef, $max, $old_id ); >+ $dbh->do( q|UPDATE notifys SET borrowernumber = ? WHERE borrowernumber = ?|, undef, $max, $old_id ); # Just in case, see bug 10021 >+ $dbh->do( q|UPDATE saved_sql SET borrowernumber = ? WHERE borrowernumber = ?|, undef, $max, $old_id ); >+ $dbh->do( q|UPDATE search_history SET userid = ? WHERE userid = ?|, undef, $max, $old_id ); >+ $dbh->do( q|UPDATE statistics SET borrowernumber = ? WHERE borrowernumber = ?|, undef, $max, $old_id ); >+ $dbh->do( q|UPDATE aqbudgets SET budget_owner_id = ? WHERE budget_owner_id = ?|, undef, $max, $old_id ); >+ $dbh->do( q|UPDATE aqbasket SET authorisedby = ? WHERE authorisedby = ?|, undef, $max, $old_id ); >+ $dbh->do( q|UPDATE suggestions SET suggestedby = ? WHERE suggestedby = ?|, undef, $max, $old_id ); >+ $dbh->do( q|UPDATE suggestions SET managedby = ? WHERE managedby = ?|, undef, $max, $old_id ); >+ $dbh->do( q|UPDATE suggestions SET acceptedby = ? WHERE acceptedby = ?|, undef, $max, $old_id ); >+ $dbh->do( q|UPDATE suggestions SET rejectedby = ? WHERE rejectedby = ?|, undef, $max, $old_id ); >+ } elsif ( $table eq 'biblio' ) { >+ $dbh->do( q|UPDATE import_biblios SET matched_biblionumber = ? WHERE matched_biblionumber = ?|, undef, $max, $old_id ); >+ $dbh->do( q|UPDATE oai_sets_biblios SET biblionumber = ? WHERE biblionumber = ?|, undef, $max, $old_id ); >+ $dbh->do( q|UPDATE serial SET biblionumber = ? WHERE biblionumber = ?|, undef, $max, $old_id ); >+ $dbh->do( q|UPDATE subscription SET biblionumber = ? WHERE biblionumber = ?|, undef, $max, $old_id ); >+ $dbh->do( q|UPDATE subscriptionhistory SET biblionumber = ? WHERE biblionumber = ?|, undef, $max, $old_id ); >+ $dbh->do( q|UPDATE tmp_holdsqueue SET biblionumber = ? WHERE biblionumber = ?|, undef, $max, $old_id ); >+ $dbh->do( q|UPDATE suggestions SET biblionumber = ? WHERE biblionumber = ?|, undef, $max, $old_id ); >+ $dbh->do( q|UPDATE linktracker SET biblionumber = ? WHERE biblionumber = ?|, undef, $max, $old_id ); >+ } elsif ( $table eq 'items' ) { >+ $dbh->do( q|UPDATE collections_tracking SET itemnumber = ? WHERE itemnumber = ?|, undef, $max, $old_id ); >+ $dbh->do( q|UPDATE import_items SET itemnumber = ? WHERE itemnumber = ?|, undef, $max, $old_id ); >+ $dbh->do( q|UPDATE notifys SET itemnumber = ? WHERE itemnumber = ?|, undef, $max, $old_id ); # Just in case, see bug 10021 >+ $dbh->do( q|UPDATE statistics SET itemnumber = ? WHERE itemnumber = ?|, undef, $max, $old_id ); >+ $dbh->do( q|UPDATE tmp_holdsqueue SET itemnumber = ? WHERE itemnumber = ?|, undef, $max, $old_id ); >+ $dbh->do( q|UPDATE accountlines SET itemnumber = ? WHERE itemnumber = ?|, undef, $max, $old_id ); >+ } > }; > if ($@) { > print "Something went wrong, rolling back!\n"; >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 19016
:
65402
| 65403 |
65456
|
65710
|
68015