From 30622ae8385490dd2763e75fb606334d88cbf8f6 Mon Sep 17 00:00:00 2001
From: Kyle M Hall <kyle@bywatersolutions.com>
Date: Mon, 12 Dec 2016 16:53:12 +0000
Subject: [PATCH] Bug 14570 - Update Schema

---
 Koha/Schema/Result/Borrower.pm             | 70 ++++++++++++++----------------
 Koha/Schema/Result/BorrowerModification.pm | 40 +----------------
 Koha/Schema/Result/Deletedborrower.pm      | 40 +----------------
 3 files changed, 36 insertions(+), 114 deletions(-)

diff --git a/Koha/Schema/Result/Borrower.pm b/Koha/Schema/Result/Borrower.pm
index 1fe3988..3d357ee 100644
--- a/Koha/Schema/Result/Borrower.pm
+++ b/Koha/Schema/Result/Borrower.pm
@@ -254,37 +254,11 @@ __PACKAGE__->table("borrowers");
   is_nullable: 1
   size: 255
 
-=head2 contactname
-
-  data_type: 'mediumtext'
-  is_nullable: 1
-
-=head2 contactfirstname
-
-  data_type: 'text'
-  is_nullable: 1
-
-=head2 contacttitle
-
-  data_type: 'text'
-  is_nullable: 1
-
-=head2 guarantorid
-
-  data_type: 'integer'
-  is_nullable: 1
-
 =head2 borrowernotes
 
   data_type: 'mediumtext'
   is_nullable: 1
 
-=head2 relationship
-
-  data_type: 'varchar'
-  is_nullable: 1
-  size: 100
-
 =head2 sex
 
   data_type: 'varchar'
@@ -542,18 +516,8 @@ __PACKAGE__->add_columns(
   { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
   "debarredcomment",
   { data_type => "varchar", is_nullable => 1, size => 255 },
-  "contactname",
-  { data_type => "mediumtext", is_nullable => 1 },
-  "contactfirstname",
-  { data_type => "text", is_nullable => 1 },
-  "contacttitle",
-  { data_type => "text", is_nullable => 1 },
-  "guarantorid",
-  { data_type => "integer", is_nullable => 1 },
   "borrowernotes",
   { data_type => "mediumtext", is_nullable => 1 },
-  "relationship",
-  { data_type => "varchar", is_nullable => 1, size => 100 },
   "sex",
   { data_type => "varchar", is_nullable => 1, size => 1 },
   "password",
@@ -1138,6 +1102,36 @@ __PACKAGE__->has_many(
   { cascade_copy => 0, cascade_delete => 0 },
 );
 
+=head2 relationships_guarantees
+
+Type: has_many
+
+Related object: L<Koha::Schema::Result::Relationship>
+
+=cut
+
+__PACKAGE__->has_many(
+  "relationships_guarantees",
+  "Koha::Schema::Result::Relationship",
+  { "foreign.guarantee_id" => "self.borrowernumber" },
+  { cascade_copy => 0, cascade_delete => 0 },
+);
+
+=head2 relationships_guarantors
+
+Type: has_many
+
+Related object: L<Koha::Schema::Result::Relationship>
+
+=cut
+
+__PACKAGE__->has_many(
+  "relationships_guarantors",
+  "Koha::Schema::Result::Relationship",
+  { "foreign.guarantor_id" => "self.borrowernumber" },
+  { cascade_copy => 0, cascade_delete => 0 },
+);
+
 =head2 reserves
 
 Type: has_many
@@ -1334,8 +1328,8 @@ Composing rels: L</aqorder_users> -> ordernumber
 __PACKAGE__->many_to_many("ordernumbers", "aqorder_users", "ordernumber");
 
 
-# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-10-31 10:39:35
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Lc6GQ2E7d+tyzTk3v2sWjQ
+# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-12-12 16:31:58
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:gDowcouH821/r88EUCdq9Q
 
 __PACKAGE__->belongs_to(
     "guarantor",
diff --git a/Koha/Schema/Result/BorrowerModification.pm b/Koha/Schema/Result/BorrowerModification.pm
index 0e55830..e0fa92a 100644
--- a/Koha/Schema/Result/BorrowerModification.pm
+++ b/Koha/Schema/Result/BorrowerModification.pm
@@ -264,37 +264,11 @@ __PACKAGE__->table("borrower_modifications");
   is_nullable: 1
   size: 255
 
-=head2 contactname
-
-  data_type: 'mediumtext'
-  is_nullable: 1
-
-=head2 contactfirstname
-
-  data_type: 'text'
-  is_nullable: 1
-
-=head2 contacttitle
-
-  data_type: 'text'
-  is_nullable: 1
-
-=head2 guarantorid
-
-  data_type: 'integer'
-  is_nullable: 1
-
 =head2 borrowernotes
 
   data_type: 'mediumtext'
   is_nullable: 1
 
-=head2 relationship
-
-  data_type: 'varchar'
-  is_nullable: 1
-  size: 100
-
 =head2 sex
 
   data_type: 'varchar'
@@ -516,18 +490,8 @@ __PACKAGE__->add_columns(
   { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
   "debarredcomment",
   { data_type => "varchar", is_nullable => 1, size => 255 },
-  "contactname",
-  { data_type => "mediumtext", is_nullable => 1 },
-  "contactfirstname",
-  { data_type => "text", is_nullable => 1 },
-  "contacttitle",
-  { data_type => "text", is_nullable => 1 },
-  "guarantorid",
-  { data_type => "integer", is_nullable => 1 },
   "borrowernotes",
   { data_type => "mediumtext", is_nullable => 1 },
-  "relationship",
-  { data_type => "varchar", is_nullable => 1, size => 100 },
   "sex",
   { data_type => "varchar", is_nullable => 1, size => 1 },
   "password",
@@ -583,8 +547,8 @@ __PACKAGE__->add_columns(
 __PACKAGE__->set_primary_key("verification_token", "borrowernumber");
 
 
-# Created by DBIx::Class::Schema::Loader v0.07039 @ 2015-10-06 10:38:42
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:vZ9XjkjQv0q6l2kW3KMsLg
+# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-12-12 16:31:58
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ASoLkpLc0w2j8MRLFmCeIw
 
 
 # You can replace this text with custom content, and it will be preserved on regeneration
diff --git a/Koha/Schema/Result/Deletedborrower.pm b/Koha/Schema/Result/Deletedborrower.pm
index 937a4a4..d634d05 100644
--- a/Koha/Schema/Result/Deletedborrower.pm
+++ b/Koha/Schema/Result/Deletedborrower.pm
@@ -252,37 +252,11 @@ __PACKAGE__->table("deletedborrowers");
   is_nullable: 1
   size: 255
 
-=head2 contactname
-
-  data_type: 'mediumtext'
-  is_nullable: 1
-
-=head2 contactfirstname
-
-  data_type: 'text'
-  is_nullable: 1
-
-=head2 contacttitle
-
-  data_type: 'text'
-  is_nullable: 1
-
-=head2 guarantorid
-
-  data_type: 'integer'
-  is_nullable: 1
-
 =head2 borrowernotes
 
   data_type: 'mediumtext'
   is_nullable: 1
 
-=head2 relationship
-
-  data_type: 'varchar'
-  is_nullable: 1
-  size: 100
-
 =head2 sex
 
   data_type: 'varchar'
@@ -527,18 +501,8 @@ __PACKAGE__->add_columns(
   { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
   "debarredcomment",
   { data_type => "varchar", is_nullable => 1, size => 255 },
-  "contactname",
-  { data_type => "mediumtext", is_nullable => 1 },
-  "contactfirstname",
-  { data_type => "text", is_nullable => 1 },
-  "contacttitle",
-  { data_type => "text", is_nullable => 1 },
-  "guarantorid",
-  { data_type => "integer", is_nullable => 1 },
   "borrowernotes",
   { data_type => "mediumtext", is_nullable => 1 },
-  "relationship",
-  { data_type => "varchar", is_nullable => 1, size => 100 },
   "sex",
   { data_type => "varchar", is_nullable => 1, size => 1 },
   "password",
@@ -604,8 +568,8 @@ __PACKAGE__->add_columns(
 );
 
 
-# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-09-13 17:32:29
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:pcdyzQacTbFDJ9R1k0E8mA
+# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-12-12 16:31:58
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:aww4S4vMbSwAvHi2GJW7AA
 
 
 # You can replace this text with custom code or comments, and it will be preserved on regeneration
-- 
2.1.4