Bug 23092: Add 'daterequested' to branchtransfers table
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Fri, 17 Jan 2020 12:04:07 +0000 (12:04 +0000)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 24 Jul 2020 12:09:30 +0000 (14:09 +0200)
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Koha/Schema/Result/Branchtransfer.pm
installer/data/mysql/atomicupdate/bug_23092.perl [new file with mode: 0644]
installer/data/mysql/kohastructure.sql

index a2f63b8..7fc813e 100644 (file)
@@ -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 (file)
index 0000000..a704bab
--- /dev/null
@@ -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";
+}
index 6f2f955..cc7c133 100644 (file)
@@ -925,6 +925,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