From c7abe53f682eb7507419c158f0785cf66f9836c7 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 17 Jan 2020 12:04:07 +0000 Subject: [PATCH] Bug 23092: Add 'daterequested' to branchtransfers table Signed-off-by: Nick Clemens --- Koha/Schema/Result/Branchtransfer.pm | 18 ++++++++++++++++-- .../data/mysql/atomicupdate/bug_23092.perl | 18 ++++++++++++++++++ installer/data/mysql/kohastructure.sql | 1 + 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_23092.perl diff --git a/Koha/Schema/Result/Branchtransfer.pm b/Koha/Schema/Result/Branchtransfer.pm index a2f63b81c0..7fc813e507 100644 --- a/Koha/Schema/Result/Branchtransfer.pm +++ b/Koha/Schema/Result/Branchtransfer.pm @@ -36,6 +36,13 @@ __PACKAGE__->table("branchtransfers"); is_foreign_key: 1 is_nullable: 0 +=head2 daterequested + + data_type: 'timestamp' + datetime_undef_if_invalid: 1 + default_value: current_timestamp + is_nullable: 0 + =head2 datesent data_type: 'datetime' @@ -87,6 +94,13 @@ __PACKAGE__->add_columns( is_foreign_key => 1, is_nullable => 0, }, + "daterequested", + { + data_type => "timestamp", + datetime_undef_if_invalid => 1, + default_value => \"current_timestamp", + is_nullable => 0, + }, "datesent", { data_type => "datetime", @@ -197,8 +211,8 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.07046 @ 2020-03-20 11:24:33 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:50FpCj6vWH5O8MThCy/1hA +# Created by DBIx::Class::Schema::Loader v0.07046 @ 2020-03-20 12:30:59 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:G5GZTxF8X/mcIKXmuGVWIQ sub koha_object_class { 'Koha::Item::Transfer'; diff --git a/installer/data/mysql/atomicupdate/bug_23092.perl b/installer/data/mysql/atomicupdate/bug_23092.perl new file mode 100644 index 0000000000..a704bab866 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_23092.perl @@ -0,0 +1,18 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + + unless ( column_exists('branchtransfers', 'daterequested') ) { + $dbh->do( + qq{ + ALTER TABLE branchtransfers + ADD + `daterequested` timestamp NOT NULL default CURRENT_TIMESTAMP + AFTER + `itemnumber` + } + ); + } + + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 23092 - Add 'daterequested' field to transfers table)\n"; +} diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index c5a3879662..a034dc16a2 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -920,6 +920,7 @@ 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) + `daterequested` timestamp NOT NULL default CURRENT_TIMESTAMP, -- the date the transfer was requested `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 -- 2.20.1