From 1a679de4a1c2dcb3ff7e1e2098f3d968cd777104 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 15 Sep 2021 16:30:15 +0100 Subject: [PATCH] Bug 29002: DBIC Schema Build Rebuild of DBIx::Class schema files for the new table and relations added. Signed-off-by: Martin Renvoize Signed-off-by: Janet McGowan Signed-off-by: Caroline Cyr La Rose Signed-off-by: Laurence Rault Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi --- Koha/Schema/Result/Biblio.pm | 19 +++- Koha/Schema/Result/Booking.pm | 181 +++++++++++++++++++++++++++++++++ Koha/Schema/Result/Borrower.pm | 19 +++- Koha/Schema/Result/Item.pm | 15 +++ 4 files changed, 230 insertions(+), 4 deletions(-) create mode 100644 Koha/Schema/Result/Booking.pm diff --git a/Koha/Schema/Result/Biblio.pm b/Koha/Schema/Result/Biblio.pm index 24a2688cae..d1277e7ce8 100644 --- a/Koha/Schema/Result/Biblio.pm +++ b/Koha/Schema/Result/Biblio.pm @@ -255,6 +255,21 @@ __PACKAGE__->has_many( { cascade_copy => 0, cascade_delete => 0 }, ); +=head2 bookings + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "bookings", + "Koha::Schema::Result::Booking", + { "foreign.biblio_id" => "self.biblionumber" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + =head2 club_holds Type: has_many @@ -601,8 +616,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.07049 @ 2023-05-05 12:10:09 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:xDa15D5QckMdwVzVy4FX2g +# Created by DBIx::Class::Schema::Loader v0.07049 @ 2023-05-09 07:11:30 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:AZgt+4mVV/QYtSsdhxmaBQ __PACKAGE__->has_many( "biblioitem", diff --git a/Koha/Schema/Result/Booking.pm b/Koha/Schema/Result/Booking.pm new file mode 100644 index 0000000000..4c3a971529 --- /dev/null +++ b/Koha/Schema/Result/Booking.pm @@ -0,0 +1,181 @@ +use utf8; +package Koha::Schema::Result::Booking; + +# Created by DBIx::Class::Schema::Loader +# DO NOT MODIFY THE FIRST PART OF THIS FILE + +=head1 NAME + +Koha::Schema::Result::Booking + +=cut + +use strict; +use warnings; + +use base 'DBIx::Class::Core'; + +=head1 TABLE: C + +=cut + +__PACKAGE__->table("bookings"); + +=head1 ACCESSORS + +=head2 booking_id + + data_type: 'integer' + is_auto_increment: 1 + is_nullable: 0 + +primary key + +=head2 patron_id + + data_type: 'integer' + default_value: 0 + is_foreign_key: 1 + is_nullable: 0 + +foreign key from the borrowers table defining which patron this booking is for + +=head2 biblio_id + + data_type: 'integer' + default_value: 0 + is_foreign_key: 1 + is_nullable: 0 + +foreign key from the biblio table defining which bib record this booking is on + +=head2 item_id + + data_type: 'integer' + is_foreign_key: 1 + is_nullable: 1 + +foreign key from the items table defining the specific item the patron has placed a booking for + +=head2 start_date + + data_type: 'datetime' + datetime_undef_if_invalid: 1 + is_nullable: 1 + +the start date of the booking + +=head2 end_date + + data_type: 'datetime' + datetime_undef_if_invalid: 1 + is_nullable: 1 + +the end date of the booking + +=cut + +__PACKAGE__->add_columns( + "booking_id", + { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, + "patron_id", + { + data_type => "integer", + default_value => 0, + is_foreign_key => 1, + is_nullable => 0, + }, + "biblio_id", + { + data_type => "integer", + default_value => 0, + is_foreign_key => 1, + is_nullable => 0, + }, + "item_id", + { data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, + "start_date", + { + data_type => "datetime", + datetime_undef_if_invalid => 1, + is_nullable => 1, + }, + "end_date", + { + data_type => "datetime", + datetime_undef_if_invalid => 1, + is_nullable => 1, + }, +); + +=head1 PRIMARY KEY + +=over 4 + +=item * L + +=back + +=cut + +__PACKAGE__->set_primary_key("booking_id"); + +=head1 RELATIONS + +=head2 biblio + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "biblio", + "Koha::Schema::Result::Biblio", + { biblionumber => "biblio_id" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, +); + +=head2 item + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "item", + "Koha::Schema::Result::Item", + { itemnumber => "item_id" }, + { + is_deferrable => 1, + join_type => "LEFT", + on_delete => "CASCADE", + on_update => "CASCADE", + }, +); + +=head2 patron + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "patron", + "Koha::Schema::Result::Borrower", + { borrowernumber => "patron_id" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, +); + + +# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-11-04 10:01:46 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:LoOYu7IflBkC4+VUZLd+Tg + + +# You can replace this text with custom code or comments, and it will be preserved on regeneration +1; diff --git a/Koha/Schema/Result/Borrower.pm b/Koha/Schema/Result/Borrower.pm index ff7e89e183..a17813c7d9 100644 --- a/Koha/Schema/Result/Borrower.pm +++ b/Koha/Schema/Result/Borrower.pm @@ -1067,6 +1067,21 @@ __PACKAGE__->has_many( { cascade_copy => 0, cascade_delete => 0 }, ); +=head2 bookings + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "bookings", + "Koha::Schema::Result::Booking", + { "foreign.patron_id" => "self.borrowernumber" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + =head2 borrower_attributes Type: has_many @@ -2143,8 +2158,8 @@ Composing rels: L -> permission __PACKAGE__->many_to_many("permissions", "user_permissions", "permission"); -# Created by DBIx::Class::Schema::Loader v0.07049 @ 2023-11-01 18:21:38 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:5wLpO0InLt7EnwlICnhqHg +# Created by DBIx::Class::Schema::Loader v0.07049 @ 2023-05-09 07:11:30 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:6Dg1BEP0T6C3J6hQPn4Wkw __PACKAGE__->has_many( "restrictions", diff --git a/Koha/Schema/Result/Item.pm b/Koha/Schema/Result/Item.pm index d75c56ac9a..b23a4388d3 100644 --- a/Koha/Schema/Result/Item.pm +++ b/Koha/Schema/Result/Item.pm @@ -602,6 +602,21 @@ __PACKAGE__->belongs_to( { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, ); +=head2 bookings + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "bookings", + "Koha::Schema::Result::Booking", + { "foreign.item_id" => "self.itemnumber" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + =head2 branchtransfers Type: has_many -- 2.39.5