From 6a786fb43c8e79ce072e77fc615ea7f7496baede 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 --- Koha/Schema/Result/Biblio.pm | 15 +++ Koha/Schema/Result/Booking.pm | 181 +++++++++++++++++++++++++++++++++ Koha/Schema/Result/Borrower.pm | 19 +++- Koha/Schema/Result/Item.pm | 19 +++- 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 10e717b369..1ae119247c 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.biblionumber" => "self.biblionumber" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + =head2 club_holds Type: has_many diff --git a/Koha/Schema/Result/Booking.pm b/Koha/Schema/Result/Booking.pm new file mode 100644 index 0000000000..a06b1153aa --- /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 borrowernumber + + 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 biblionumber + + 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 itemnumber + + 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 }, + "borrowernumber", + { + data_type => "integer", + default_value => 0, + is_foreign_key => 1, + is_nullable => 0, + }, + "biblionumber", + { + data_type => "integer", + default_value => 0, + is_foreign_key => 1, + is_nullable => 0, + }, + "itemnumber", + { 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 biblionumber + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "biblionumber", + "Koha::Schema::Result::Biblio", + { biblionumber => "biblionumber" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, +); + +=head2 borrowernumber + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "borrowernumber", + "Koha::Schema::Result::Borrower", + { borrowernumber => "borrowernumber" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, +); + +=head2 itemnumber + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "itemnumber", + "Koha::Schema::Result::Item", + { itemnumber => "itemnumber" }, + { + is_deferrable => 1, + join_type => "LEFT", + on_delete => "CASCADE", + on_update => "CASCADE", + }, +); + + +# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-09-15 15:26:37 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:1M7/k3YWVzO2kH517vNNtg + + +# 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 d4c13f1f3d..3548280b16 100644 --- a/Koha/Schema/Result/Borrower.pm +++ b/Koha/Schema/Result/Borrower.pm @@ -1004,6 +1004,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.borrowernumber" => "self.borrowernumber" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + =head2 borrower_attributes Type: has_many @@ -1905,8 +1920,8 @@ Composing rels: L -> ordernumber __PACKAGE__->many_to_many("ordernumbers", "aqorder_users", "ordernumber"); -# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-09-20 12:00:15 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:9g9WsdsdPINi2NP4H2A+CA +# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-09-15 15:26:37 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:gT3Z4IHnObg8sCkBk5yrMA __PACKAGE__->add_columns( '+anonymized' => { is_boolean => 1 }, diff --git a/Koha/Schema/Result/Item.pm b/Koha/Schema/Result/Item.pm index a53e10e98a..4bed9ee756 100644 --- a/Koha/Schema/Result/Item.pm +++ b/Koha/Schema/Result/Item.pm @@ -584,6 +584,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.itemnumber" => "self.itemnumber" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + =head2 branchtransfers Type: has_many @@ -865,8 +880,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-08-27 08:42:21 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:SjZn3haOtUZWu1jrMigjNQ +# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-09-15 15:26:37 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:2Y2jtctgzsfhwCbaHjHXkw __PACKAGE__->belongs_to( biblioitem => "Koha::Schema::Result::Biblioitem", "biblioitemnumber" ); -- 2.20.1