Bugzilla – Attachment 40075 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-.patch (text/plain), 5.84 KB, created by
Olli-Antti Kivilahti
on 2015-06-10 13:59:08 UTC
(
hide
)
Description:
Bug 14187 - branchtransfer needs a primary key (id) for DBIx and common sense.
Filename:
MIME Type:
Creator:
Olli-Antti Kivilahti
Created:
2015-06-10 13:59:08 UTC
Size:
5.84 KB
patch
obsolete
>From cddd621ab6aa532d48f28e661bff274c40b31a18 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 | 5 ++-- > Koha/Schema/Result/Branchtransfer.pm | 45 ++++++++++++++++++-------------- > installer/data/mysql/kohastructure.sql | 2 ++ > installer/data/mysql/updatedatabase.pl | 7 +++++ > 4 files changed, 37 insertions(+), 22 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index f991680..0363739 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -3111,7 +3111,8 @@ sub GetTransfers { > my $query = ' > SELECT datesent, > frombranch, >- tobranch >+ tobranch, >+ branchtransfer_id > FROM branchtransfers > WHERE itemnumber = ? > AND datearrived IS NULL >@@ -3135,7 +3136,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/Koha/Schema/Result/Branchtransfer.pm b/Koha/Schema/Result/Branchtransfer.pm >index 1976ffd..958c506 100644 >--- a/Koha/Schema/Result/Branchtransfer.pm >+++ b/Koha/Schema/Result/Branchtransfer.pm >@@ -1,21 +1,17 @@ >-use utf8; > package Koha::Schema::Result::Branchtransfer; > > # Created by DBIx::Class::Schema::Loader > # DO NOT MODIFY THE FIRST PART OF THIS FILE > >-=head1 NAME >- >-Koha::Schema::Result::Branchtransfer >- >-=cut >- > use strict; > use warnings; > > use base 'DBIx::Class::Core'; > >-=head1 TABLE: C<branchtransfers> >+ >+=head1 NAME >+ >+Koha::Schema::Result::Branchtransfer > > =cut > >@@ -23,6 +19,12 @@ __PACKAGE__->table("branchtransfers"); > > =head1 ACCESSORS > >+=head2 branchtransfer_id >+ >+ data_type: 'integer' >+ is_auto_increment: 1 >+ is_nullable: 0 >+ > =head2 itemnumber > > data_type: 'integer' >@@ -66,6 +68,8 @@ __PACKAGE__->table("branchtransfers"); > =cut > > __PACKAGE__->add_columns( >+ "branchtransfer_id", >+ { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, > "itemnumber", > { > data_type => "integer", >@@ -104,6 +108,7 @@ __PACKAGE__->add_columns( > "comments", > { data_type => "mediumtext", is_nullable => 1 }, > ); >+__PACKAGE__->set_primary_key("branchtransfer_id"); > > =head1 RELATIONS > >@@ -122,39 +127,39 @@ __PACKAGE__->belongs_to( > { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, > ); > >-=head2 itemnumber >+=head2 tobranch > > Type: belongs_to > >-Related object: L<Koha::Schema::Result::Item> >+Related object: L<Koha::Schema::Result::Branch> > > =cut > > __PACKAGE__->belongs_to( >- "itemnumber", >- "Koha::Schema::Result::Item", >- { itemnumber => "itemnumber" }, >+ "tobranch", >+ "Koha::Schema::Result::Branch", >+ { branchcode => "tobranch" }, > { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, > ); > >-=head2 tobranch >+=head2 itemnumber > > Type: belongs_to > >-Related object: L<Koha::Schema::Result::Branch> >+Related object: L<Koha::Schema::Result::Item> > > =cut > > __PACKAGE__->belongs_to( >- "tobranch", >- "Koha::Schema::Result::Branch", >- { branchcode => "tobranch" }, >+ "itemnumber", >+ "Koha::Schema::Result::Item", >+ { itemnumber => "itemnumber" }, > { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, > ); > > >-# Created by DBIx::Class::Schema::Loader v0.07025 @ 2013-10-14 20:56:21 >-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:NPbH+5o2BVPj8yeoUqEavw >+# Created by DBIx::Class::Schema::Loader v0.07010 @ 2015-05-27 18:14:12 >+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:IKdPAJHJdYM3MHxnj6Mxzg > > > # You can replace this text with custom content, and it will be preserved on regeneration >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index c41710c..b54468a 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -440,12 +440,14 @@ CREATE TABLE `branchrelations` ( -- this table links libraries/branches to group > > 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/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 9ee74c1..c97f41f 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -8490,6 +8490,13 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { > SetVersion($DBversion); > } > >+$DBversion = "3.99.00.XXX"; >+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);"); >+ print "Upgrade to $DBversion done (Bug 14187 - branchtransfer needs a primary key (id) for DBIx and common sense.)\n"; >+ SetVersion ($DBversion); >+} >+ > $DBversion = "3.15.00.050"; > if ( CheckVersion($DBversion) ) { > $dbh->do(" >-- >1.7.9.5
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