From 617a2bb787a622abb9122f86c3aad70114ea1a83 Mon Sep 17 00:00:00 2001
From: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Date: Fri, 11 Mar 2022 13:07:59 +0000
Subject: [PATCH] Bug 30275: DBIC Schema Changes

---
 Koha/Schema/Result/Borrower.pm        |  19 +++-
 Koha/Schema/Result/CheckoutRenewal.pm | 134 ++++++++++++++++++++++++++
 2 files changed, 151 insertions(+), 2 deletions(-)
 create mode 100644 Koha/Schema/Result/CheckoutRenewal.pm

diff --git a/Koha/Schema/Result/Borrower.pm b/Koha/Schema/Result/Borrower.pm
index 5d43423cb8..a800cc0ffa 100644
--- a/Koha/Schema/Result/Borrower.pm
+++ b/Koha/Schema/Result/Borrower.pm
@@ -1139,6 +1139,21 @@ __PACKAGE__->belongs_to(
   { is_deferrable => 1, on_delete => "RESTRICT", on_update => "RESTRICT" },
 );
 
+=head2 checkout_renewals
+
+Type: has_many
+
+Related object: L<Koha::Schema::Result::CheckoutRenewal>
+
+=cut
+
+__PACKAGE__->has_many(
+  "checkout_renewals",
+  "Koha::Schema::Result::CheckoutRenewal",
+  { "foreign.renewed_by" => "self.borrowernumber" },
+  { cascade_copy => 0, cascade_delete => 0 },
+);
+
 =head2 club_enrollments
 
 Type: has_many
@@ -1915,8 +1930,8 @@ Composing rels: L</user_permissions> -> permission
 __PACKAGE__->many_to_many("permissions", "user_permissions", "permission");
 
 
-# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-02-25 00:33:23
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:qPGKczsaKaLxxiNzZS5zdQ
+# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-03-11 13:06:49
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:LFLwyfXgP+y1X1hfj7xL9Q
 
 __PACKAGE__->has_many(
   "extended_attributes",
diff --git a/Koha/Schema/Result/CheckoutRenewal.pm b/Koha/Schema/Result/CheckoutRenewal.pm
new file mode 100644
index 0000000000..aa323f5154
--- /dev/null
+++ b/Koha/Schema/Result/CheckoutRenewal.pm
@@ -0,0 +1,134 @@
+use utf8;
+package Koha::Schema::Result::CheckoutRenewal;
+
+# Created by DBIx::Class::Schema::Loader
+# DO NOT MODIFY THE FIRST PART OF THIS FILE
+
+=head1 NAME
+
+Koha::Schema::Result::CheckoutRenewal
+
+=cut
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class::Core';
+
+=head1 TABLE: C<checkout_renewals>
+
+=cut
+
+__PACKAGE__->table("checkout_renewals");
+
+=head1 ACCESSORS
+
+=head2 id
+
+  data_type: 'integer'
+  is_auto_increment: 1
+  is_nullable: 0
+
+=head2 issue_id
+
+  data_type: 'integer'
+  is_nullable: 1
+
+the id of the issue this renewal pertains to
+
+=head2 renewed_by
+
+  data_type: 'integer'
+  is_foreign_key: 1
+  is_nullable: 1
+
+the id of the user who processed the renewal
+
+=head2 seen
+
+  data_type: 'tinyint'
+  default_value: 0
+  is_nullable: 1
+
+boolean denoting whether the item was present or not
+
+=head2 interface
+
+  data_type: 'varchar'
+  is_nullable: 0
+  size: 16
+
+the interface this renewal took place on
+
+=head2 timestamp
+
+  data_type: 'timestamp'
+  datetime_undef_if_invalid: 1
+  default_value: current_timestamp
+  is_nullable: 0
+
+the date and time the renewal took place
+
+=cut
+
+__PACKAGE__->add_columns(
+  "id",
+  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
+  "issue_id",
+  { data_type => "integer", is_nullable => 1 },
+  "renewed_by",
+  { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
+  "seen",
+  { data_type => "tinyint", default_value => 0, is_nullable => 1 },
+  "interface",
+  { data_type => "varchar", is_nullable => 0, size => 16 },
+  "timestamp",
+  {
+    data_type => "timestamp",
+    datetime_undef_if_invalid => 1,
+    default_value => \"current_timestamp",
+    is_nullable => 0,
+  },
+);
+
+=head1 PRIMARY KEY
+
+=over 4
+
+=item * L</id>
+
+=back
+
+=cut
+
+__PACKAGE__->set_primary_key("id");
+
+=head1 RELATIONS
+
+=head2 renewed_by
+
+Type: belongs_to
+
+Related object: L<Koha::Schema::Result::Borrower>
+
+=cut
+
+__PACKAGE__->belongs_to(
+  "renewed_by",
+  "Koha::Schema::Result::Borrower",
+  { borrowernumber => "renewed_by" },
+  {
+    is_deferrable => 1,
+    join_type     => "LEFT",
+    on_delete     => "SET NULL",
+    on_update     => "CASCADE",
+  },
+);
+
+
+# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-03-11 16:07:00
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:GVP3hrWfNjeMXt9BKUdA8g
+
+
+# You can replace this text with custom code or comments, and it will be preserved on regeneration
+1;
-- 
2.20.1