From 16d18552b97d617024bbef9ebf48be5e8f467730 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 21 Dec 2018 12:10:02 +0000 Subject: [PATCH] Bug 22008: DBIC Schema Updates --- Koha/Schema/Result/Accountline.pm | 52 ++++++++++++++++++++++++++++--- Koha/Schema/Result/Borrower.pm | 19 +++++++++-- Koha/Schema/Result/Issue.pm | 19 +++++++++-- 3 files changed, 81 insertions(+), 9 deletions(-) diff --git a/Koha/Schema/Result/Accountline.pm b/Koha/Schema/Result/Accountline.pm index 641b632ee7..ab8ca33254 100644 --- a/Koha/Schema/Result/Accountline.pm +++ b/Koha/Schema/Result/Accountline.pm @@ -32,6 +32,7 @@ __PACKAGE__->table("accountlines"); =head2 issue_id data_type: 'integer' + is_foreign_key: 1 is_nullable: 1 =head2 borrowernumber @@ -108,6 +109,7 @@ __PACKAGE__->table("accountlines"); =head2 manager_id data_type: 'integer' + is_foreign_key: 1 is_nullable: 1 =cut @@ -116,7 +118,7 @@ __PACKAGE__->add_columns( "accountlines_id", { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, "issue_id", - { data_type => "integer", is_nullable => 1 }, + { data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, "borrowernumber", { data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, "accountno", @@ -147,7 +149,7 @@ __PACKAGE__->add_columns( "note", { data_type => "mediumtext", is_nullable => 1 }, "manager_id", - { data_type => "integer", is_nullable => 1 }, + { data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, ); =head1 PRIMARY KEY @@ -214,6 +216,26 @@ __PACKAGE__->belongs_to( }, ); +=head2 issue + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "issue", + "Koha::Schema::Result::Issue", + { issue_id => "issue_id" }, + { + is_deferrable => 1, + join_type => "LEFT", + on_delete => "SET NULL", + on_update => "CASCADE", + }, +); + =head2 itemnumber Type: belongs_to @@ -230,13 +252,33 @@ __PACKAGE__->belongs_to( is_deferrable => 1, join_type => "LEFT", on_delete => "SET NULL", - on_update => "SET NULL", + on_update => "CASCADE", + }, +); + +=head2 manager + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "manager", + "Koha::Schema::Result::Borrower", + { borrowernumber => "manager_id" }, + { + is_deferrable => 1, + join_type => "LEFT", + on_delete => "SET NULL", + on_update => "CASCADE", }, ); -# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-12-19 16:19:16 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:kvBIJshNRsm/HYJBbhm0IA +# Created by DBIx::Class::Schema::Loader v0.07046 @ 2018-12-21 12:01:41 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:oAlRy53c2P0qVSV27fJ+1Q sub koha_objects_class { 'Koha::Account::Lines'; diff --git a/Koha/Schema/Result/Borrower.pm b/Koha/Schema/Result/Borrower.pm index 8e4580f7e0..17daa7a457 100644 --- a/Koha/Schema/Result/Borrower.pm +++ b/Koha/Schema/Result/Borrower.pm @@ -710,6 +710,21 @@ __PACKAGE__->has_many( { cascade_copy => 0, cascade_delete => 0 }, ); +=head2 accountlines_managers + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "accountlines_managers", + "Koha::Schema::Result::Accountline", + { "foreign.manager_id" => "self.borrowernumber" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + =head2 api_keys Type: has_many @@ -1431,8 +1446,8 @@ Composing rels: L -> ordernumber __PACKAGE__->many_to_many("ordernumbers", "aqorder_users", "ordernumber"); -# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-10-27 13:16:48 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:c3Tb59Kku0Hh+tsVV5eCDg +# Created by DBIx::Class::Schema::Loader v0.07046 @ 2018-12-21 12:01:41 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:cdZJs0uL23mwlAoicWvncQ __PACKAGE__->belongs_to( "guarantor", diff --git a/Koha/Schema/Result/Issue.pm b/Koha/Schema/Result/Issue.pm index e82886aae5..866292d165 100644 --- a/Koha/Schema/Result/Issue.pm +++ b/Koha/Schema/Result/Issue.pm @@ -207,6 +207,21 @@ __PACKAGE__->add_unique_constraint("itemnumber", ["itemnumber"]); =head1 RELATIONS +=head2 accountlines + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "accountlines", + "Koha::Schema::Result::Accountline", + { "foreign.issue_id" => "self.issue_id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + =head2 borrowernumber Type: belongs_to @@ -248,8 +263,8 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-07-23 13:51:40 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:+mlcId4odhAFp3HHgV/+tg +# Created by DBIx::Class::Schema::Loader v0.07046 @ 2018-12-21 12:01:42 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:OsRHKP1Qe5KuToNDALVW4Q __PACKAGE__->belongs_to( "borrower", -- 2.19.2