Bugzilla – Attachment 58881 Details for
Bug 14187
branchtransfer needs a primary key (id) for DBIx and common sense.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14187: branchtransfer needs a primary key (id) for DBIx and common sense.
Bug-14187-branchtransfer-needs-a-primary-key-id-fo.patch (text/plain), 5.32 KB, created by
Tomás Cohen Arazi (tcohen)
on 2017-01-12 15:44:29 UTC
(
hide
)
Description:
Bug 14187: branchtransfer needs a primary key (id) for DBIx and common sense.
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2017-01-12 15:44:29 UTC
Size:
5.32 KB
patch
obsolete
>From c2ad621e82baf15abef554ee7be749362d73e751 Mon Sep 17 00:00:00 2001 >From: Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> >Date: Tue, 12 May 2015 10:19:05 +0300 >Subject: [PATCH] Bug 14187: branchtransfer needs a primary key (id) for DBIx > and common sense. > >* C4/Circulation.pm (GetTransfers, GetTransfersFromTo): Also return > branchtransfer_id in return columns. >* installer/data/mysql/atomicupdate/14187.perl: New file. >* installer/data/mysql/kohastructure.sql: Modify branchtransfers structure. >* t/db_dependent/Circulation/transfers.t: Update tests to expect > branchtransfer_id. > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> > >Test plan successful on all steps. > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Amended patch: Remove Schema changes from this patch >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > C4/Circulation.pm | 5 +++-- > installer/data/mysql/atomicupdate/14187.perl | 8 ++++++++ > installer/data/mysql/kohastructure.sql | 2 ++ > t/db_dependent/Circulation/transfers.t | 16 +++++++++------- > 4 files changed, 22 insertions(+), 9 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/14187.perl > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 80ae062010..cfccbfc685 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -3205,7 +3205,8 @@ sub GetTransfers { > my $query = ' > SELECT datesent, > frombranch, >- tobranch >+ tobranch, >+ branchtransfer_id > FROM branchtransfers > WHERE itemnumber = ? > AND datearrived IS NULL >@@ -3229,7 +3230,7 @@ sub GetTransfersFromTo { > return unless ( $frombranch && $tobranch ); > my $dbh = C4::Context->dbh; > my $query = " >- SELECT itemnumber,datesent,frombranch >+ SELECT branchtransfer_id,itemnumber,datesent,frombranch > FROM branchtransfers > WHERE frombranch=? > AND tobranch=? >diff --git a/installer/data/mysql/atomicupdate/14187.perl b/installer/data/mysql/atomicupdate/14187.perl >new file mode 100644 >index 0000000000..02022b4c37 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/14187.perl >@@ -0,0 +1,8 @@ >+$DBversion = 'XXX'; # will be replaced by the RM >+if( CheckVersion( $DBversion ) ) { >+ $dbh->do("ALTER TABLE branchtransfers ADD COLUMN branchtransfer_id int(12) NOT NULL auto_increment FIRST, ADD CONSTRAINT PRIMARY KEY (branchtransfer_id);"); >+ >+ # Always end with this (adjust the bug info) >+ SetVersion( $DBversion ); >+ print "Upgrade to $DBversion done (Bug 14187 - branchtransfer needs a primary key (id) for DBIx and common sense.)\n"; >+} >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 9e9302bab2..91d83df7a8 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -1003,12 +1003,14 @@ CREATE TABLE `default_branch_item_rules` ( > > DROP TABLE IF EXISTS `branchtransfers`; > CREATE TABLE `branchtransfers` ( -- information for items that are in transit between branches >+ `branchtransfer_id` int(12) NOT NULL auto_increment, -- primary key > `itemnumber` int(11) NOT NULL default 0, -- the itemnumber that it is in transit (items.itemnumber) > `datesent` datetime default NULL, -- the date the transfer was initialized > `frombranch` varchar(10) NOT NULL default '', -- the branch the transfer is coming from > `datearrived` datetime default NULL, -- the date the transfer arrived at its destination > `tobranch` varchar(10) NOT NULL default '', -- the branch the transfer was going to > `comments` mediumtext, -- any comments related to the transfer >+ PRIMARY KEY (`branchtransfer_id`), > KEY `frombranch` (`frombranch`), > KEY `tobranch` (`tobranch`), > KEY `itemnumber` (`itemnumber`), >diff --git a/t/db_dependent/Circulation/transfers.t b/t/db_dependent/Circulation/transfers.t >index 1e83f33168..5abe5e5a9b 100644 >--- a/t/db_dependent/Circulation/transfers.t >+++ b/t/db_dependent/Circulation/transfers.t >@@ -125,7 +125,7 @@ is(CreateBranchTransferLimit(undef,$branchcode_2),undef, > my @transfers = GetTransfers($item_id1); > cmp_deeply( > \@transfers, >- [ re('^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$'), $branchcode_1, $branchcode_2 ], >+ [ re('^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$'), $branchcode_1, $branchcode_2, re('[0-9]*') ], > "Transfers of the item1" > ); #NOTE: Only the first transfer is returned > @transfers = GetTransfers; >@@ -142,14 +142,16 @@ cmp_deeply( > \@transferfrom1to2, > [ > { >- itemnumber => $item_id1, >- datesent => re('^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$'), >- frombranch => $branchcode_1 >+ branchtransfer_id => re('[0-9]*'), >+ itemnumber => $item_id1, >+ datesent => re('^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$'), >+ frombranch => $branchcode_1 > }, > { >- itemnumber => $item_id2, >- datesent => re('^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$'), >- frombranch => $branchcode_1 >+ branchtransfer_id => re('[0-9]*'), >+ itemnumber => $item_id2, >+ datesent => re('^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$'), >+ frombranch => $branchcode_1 > } > ], > "Item1 and Item2 has been transferred from branch1 to branch2" >-- >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 14187
:
39058
|
39059
|
39060
|
40075
|
58121
|
58123
|
58124
|
58646
|
58730
|
58880
| 58881 |
58882