[Bug 15336] New: Script for merging booksellers
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15336 Bug ID: 15336 Summary: Script for merging booksellers Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Command-line Utilities Assignee: gmcharlt@gmail.com Reporter: alex.arnaud@biblibre.com QA Contact: testopia@bugs.koha-community.org CC: robin@catalyst.net.nz Sometimes, librarian create and use duplicates booksellers. Here is a command-line tool that can merge 2 booksellers. In fact, it moves baskets, basketgroups, contracts etc ... in the target bookseller. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15336 Alex Arnaud <alex.arnaud@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|gmcharlt@gmail.com |alex.arnaud@biblibre.com -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15336 --- Comment #1 from Alex Arnaud <alex.arnaud@biblibre.com> --- Created attachment 45521 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=45521&action=edit Bug 15336 - New command-line script: merge_bookseller.pl 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. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15336 Alex Arnaud <alex.arnaud@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15336 Marc Véron <veron@veron.ch> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #45521|0 |1 is obsolete| | --- Comment #2 from Marc Véron <veron@veron.ch> --- Created attachment 45530 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=45530&action=edit Bug 15336 - New command-line script: merge_bookseller.pl 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> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15336 Marc Véron <veron@veron.ch> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |veron@veron.ch Patch complexity|--- |Small patch Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15336 --- Comment #3 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- Comment on attachment 45530 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=45530 Bug 15336 - New command-line script: merge_bookseller.pl Review of attachment 45530: --> (http://bugs.koha-community.org/bugzilla3/page.cgi?id=splinter.html&bug=15336&attachment=45530) ----------------------------------------------------------------- ::: misc/migration_tools/merge_booksellers.pl @@ +1,1 @@
+#!/usr/bin/perl
The copyright is missing. @@ +1,4 @@
+#!/usr/bin/perl +# Script that merge source bookseller (-f) into target bookseller (-t). + +use strict;
use Modern::Perl; @@ +18,5 @@
+ 't:s' => \$mergeto, + 'c' => \$confirm, +); + +if ($help || !$mergefrom || !$mergeto) {
you could also test mergefrom == mergeto @@ +30,5 @@
+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)) {
What about the tables items, deleteditems, subscription? @@ +31,5 @@
+die "Unknown bookseller id ($mergeto)" unless $to_bookseller; + +my $report; +foreach (qw(Aqbasketgroup Aqbasket Aqcontract Aqcontact Aqinvoice)) { + my $rs = Koha::Database->new()->schema->resultset($_);
Please don't use $_ @@ +47,5 @@
+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 {
use Pod::Usage; see misc/export_records.pl for an example. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15336 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jonathan.druart@bugs.koha-c | |ommunity.org Status|Signed Off |Failed QA -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15336 --- Comment #4 from Alex Arnaud <alex.arnaud@biblibre.com> ---
@@ +30,5 @@
+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)) {
What about the tables items, deleteditems, subscription?
I checked aqbooksellers relationship on this page: http://schema.koha-community.org/tables/aqbooksellers.html that doesn't mention items, deleteditems or subscription tables. Looks that the schema is not up to date. Is there any other tables i forgot to handle ? -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15336 --- Comment #5 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- grep booksellerid installer/data/mysql/kohastructure.sql And look at the FK, there is none on these 3 tables, that's why you haven't found them. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15336 --- Comment #6 from Alex Arnaud <alex.arnaud@biblibre.com> --- Created attachment 45607 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=45607&action=edit Bug 15336 - Fix QA comments -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15336 Alex Arnaud <alex.arnaud@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Failed QA |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15336 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |katrin.fischer@bsz-bw.de --- Comment #7 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- I wonder if it wouldn't be nice to offer this option from the GUI instead of it only being available via command line. Having the logic in one of the modules would also allow for unit testing and make me feel better about this :) -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15336 --- Comment #8 from Marc Véron <veron@veron.ch> --- (In reply to Katrin Fischer from comment #7)
I wonder if it wouldn't be nice to offer this option from the GUI instead of it only being available via command line. Having the logic in one of the modules would also allow for unit testing and make me feel better about this :)
Good idea! -- You are receiving this mail because: You are watching all bug changes.
I wonder if it wouldn't be nice to offer this option from the GUI instead of it only being available via command line. Having the logic in one of the modules would also allow for unit testing and make me feel better about this :) The sponsored dev was related to something in command line : that's considered a back-office stuff, that has to be done "once", to fix some inconsistencies in
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15336 Paul Poulain <paul.poulain@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |paul.poulain@biblibre.com --- Comment #9 from Paul Poulain <paul.poulain@biblibre.com> --- (In reply to Katrin Fischer from comment #7) the database. so let's sign/qa/push this one, and if someone else feel it's useful to have it as command line, that's for another ticket ! -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15336 --- Comment #10 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- I think even as a command line script it's worth while to have this as a function in the proper place and testable - don't you think? -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15336 Alex Arnaud <alex.arnaud@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |ASSIGNED --- Comment #11 from Alex Arnaud <alex.arnaud@biblibre.com> --- I started to move code related to "merging" into Koha::Acquisition::Bookseller" (and use it in the command line script) so that i can test it and if we want to have this option from GUI it could be done in another BZ. Patch is coming tomorrow. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15336 --- Comment #12 from Alex Arnaud <alex.arnaud@biblibre.com> --- Created attachment 45777 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=45777&action=edit Bug 15336 - Move code related to merging into Koha::Acquisition::Bookseller.pm -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15336 Alex Arnaud <alex.arnaud@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15336 --- Comment #13 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- Thank you Alex! -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org