Bugzilla – Attachment 45530 Details for
Bug 15336
Script for merging vendors
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15336 - New command-line script: merge_bookseller.pl
Bug-15336---New-command-line-script-mergebookselle.patch (text/plain), 2.94 KB, created by
Marc Véron
on 2015-12-09 13:53:05 UTC
(
hide
)
Description:
Bug 15336 - New command-line script: merge_bookseller.pl
Filename:
MIME Type:
Creator:
Marc Véron
Created:
2015-12-09 13:53:05 UTC
Size:
2.94 KB
patch
obsolete
>From 03b705eb3b2909902bdd198c9d8fc9cd211a6659 Mon Sep 17 00:00:00 2001 >From: Alex Arnaud <alex.arnaud@biblibre.com> >Date: Wed, 9 Dec 2015 11:09:58 +0100 >Subject: [PATCH] Bug 15336 - New command-line script: merge_bookseller.pl >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Test plan (i.e. merge bookseller n° 3 into the n° 6): > >run perl misc/migration_tools/merge_booksellers.pl -f 3 -t 6 -v -c > >Check that basketgroups, baskets, contacts, contracts and invoices >had moved into bookseller 6. >Check that bookseller n° 3 has been deleted. > >Remove -c (confirm) parameter to run in test mode only. > >Followed test plan, works as expected. >Signed-off-by: Marc Véron <veron@veron.ch> >--- > misc/migration_tools/merge_booksellers.pl | 69 +++++++++++++++++++++++++++++ > 1 file changed, 69 insertions(+) > create mode 100644 misc/migration_tools/merge_booksellers.pl > >diff --git a/misc/migration_tools/merge_booksellers.pl b/misc/migration_tools/merge_booksellers.pl >new file mode 100644 >index 0000000..a9f6a5d >--- /dev/null >+++ b/misc/migration_tools/merge_booksellers.pl >@@ -0,0 +1,69 @@ >+#!/usr/bin/perl >+# Script that merge source bookseller (-f) into target bookseller (-t). >+ >+use strict; >+ >+use Koha::Acquisition::Bookseller; >+use C4::Bookseller qw( DelBookseller ); >+use C4::Acquisition; >+use C4::Contract; >+ >+use Getopt::Long; >+ >+my ($help, $verbose, $mergefrom, $mergeto, $confirm); >+GetOptions( >+ 'h' => \$help, >+ 'v' => \$verbose, >+ 'f:s' => \$mergefrom, >+ 't:s' => \$mergeto, >+ 'c' => \$confirm, >+); >+ >+if ($help || !$mergefrom || !$mergeto) { >+ print_usage(); >+ die; >+} >+ >+my $from_bookseller = Koha::Acquisition::Bookseller->fetch({id => $mergefrom}); >+die "Unknown bookseller id ($mergefrom)" unless $from_bookseller; >+ >+my $to_bookseller = Koha::Acquisition::Bookseller->fetch({id => $mergeto}); >+die "Unknown bookseller id ($mergeto)" unless $to_bookseller; >+ >+my $report; >+foreach (qw(Aqbasketgroup Aqbasket Aqcontract Aqcontact Aqinvoice)) { >+ my $rs = Koha::Database->new()->schema->resultset($_); >+ $rs = $rs->search({booksellerid => $mergefrom }); >+ while (my $e = $rs->next) { >+ $e->set_column('booksellerid', $mergeto); >+ print "$_ n° " . $e->id() . " merged into bookseller n° $mergeto\n" if $verbose; >+ $e->update() if $confirm; >+ $report->{$_}++; >+ } >+} >+ >+DelBookseller($mergefrom) if $confirm; >+ >+print "\n" if $verbose; >+print_report($report); >+print "Nothing done (test only). Use confirm option to commit changes in database\n" unless $confirm; >+ >+sub print_usage { >+print <<EOF >+ Script to merge a bookselle into another >+ parameters : >+ \th : this help screen >+ \tf : the bookseller id to merge. >+ \tt : the bookseller id where to merge >+ \tc : Perform changes in database. >+EOF >+; >+} >+ >+sub print_report { >+ my $report = shift; >+ >+ foreach my $entity (keys %$report) { >+ print "$entity merged: $report->{$entity}\n"; >+ } >+} >-- >1.7.10.4
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 15336
:
45521
|
45530
|
45607
|
45777
|
49313
|
61070
|
61071
|
61104
|
61105
|
61108
|
61109
|
64595
|
66765
|
66766
|
66767
|
68676
|
72023
|
72734
|
73078