From 421d29aa4b79f43ccc04e06520e9761f291098f2 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 18 Sep 2020 12:17:08 +0200 Subject: [PATCH] Bug 26145: DBIC schema changes --- Koha/Schema/Result/Biblio.pm | 32 +++---- Koha/Schema/Result/CoverImage.pm | 151 +++++++++++++++++++++++++++++++ Koha/Schema/Result/Item.pm | 19 +++- 3 files changed, 184 insertions(+), 18 deletions(-) create mode 100644 Koha/Schema/Result/CoverImage.pm diff --git a/Koha/Schema/Result/Biblio.pm b/Koha/Schema/Result/Biblio.pm index 806faf87ad..5ee7d14cf6 100644 --- a/Koha/Schema/Result/Biblio.pm +++ b/Koha/Schema/Result/Biblio.pm @@ -210,48 +210,48 @@ __PACKAGE__->has_many( { cascade_copy => 0, cascade_delete => 0 }, ); -=head2 biblioimages +=head2 biblioitems Type: has_many -Related object: L +Related object: L =cut __PACKAGE__->has_many( - "biblioimages", - "Koha::Schema::Result::Biblioimage", + "biblioitems", + "Koha::Schema::Result::Biblioitem", { "foreign.biblionumber" => "self.biblionumber" }, { cascade_copy => 0, cascade_delete => 0 }, ); -=head2 biblioitems +=head2 club_holds Type: has_many -Related object: L +Related object: L =cut __PACKAGE__->has_many( - "biblioitems", - "Koha::Schema::Result::Biblioitem", - { "foreign.biblionumber" => "self.biblionumber" }, + "club_holds", + "Koha::Schema::Result::ClubHold", + { "foreign.biblio_id" => "self.biblionumber" }, { cascade_copy => 0, cascade_delete => 0 }, ); -=head2 club_holds +=head2 cover_images Type: has_many -Related object: L +Related object: L =cut __PACKAGE__->has_many( - "club_holds", - "Koha::Schema::Result::ClubHold", - { "foreign.biblio_id" => "self.biblionumber" }, + "cover_images", + "Koha::Schema::Result::CoverImage", + { "foreign.biblionumber" => "self.biblionumber" }, { cascade_copy => 0, cascade_delete => 0 }, ); @@ -451,8 +451,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.07046 @ 2020-04-17 09:15:51 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:p2SIq565zPyE3ZUkSuXyBA +# Created by DBIx::Class::Schema::Loader v0.07046 @ 2020-09-18 10:16:50 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:JwJoUHVr48DdTaT5qGN6tw __PACKAGE__->has_one( diff --git a/Koha/Schema/Result/CoverImage.pm b/Koha/Schema/Result/CoverImage.pm new file mode 100644 index 0000000000..7ff105dccf --- /dev/null +++ b/Koha/Schema/Result/CoverImage.pm @@ -0,0 +1,151 @@ +use utf8; +package Koha::Schema::Result::CoverImage; + +# Created by DBIx::Class::Schema::Loader +# DO NOT MODIFY THE FIRST PART OF THIS FILE + +=head1 NAME + +Koha::Schema::Result::CoverImage + +=cut + +use strict; +use warnings; + +use base 'DBIx::Class::Core'; + +=head1 TABLE: C + +=cut + +__PACKAGE__->table("cover_images"); + +=head1 ACCESSORS + +=head2 imagenumber + + data_type: 'integer' + is_auto_increment: 1 + is_nullable: 0 + +=head2 biblionumber + + data_type: 'integer' + is_foreign_key: 1 + is_nullable: 1 + +=head2 itemnumber + + data_type: 'integer' + is_foreign_key: 1 + is_nullable: 1 + +=head2 mimetype + + data_type: 'varchar' + is_nullable: 0 + size: 15 + +=head2 imagefile + + data_type: 'mediumblob' + is_nullable: 0 + +=head2 thumbnail + + data_type: 'mediumblob' + is_nullable: 0 + +=head2 timestamp + + data_type: 'timestamp' + datetime_undef_if_invalid: 1 + default_value: current_timestamp + is_nullable: 0 + +=cut + +__PACKAGE__->add_columns( + "imagenumber", + { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, + "biblionumber", + { data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, + "itemnumber", + { data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, + "mimetype", + { data_type => "varchar", is_nullable => 0, size => 15 }, + "imagefile", + { data_type => "mediumblob", is_nullable => 0 }, + "thumbnail", + { data_type => "mediumblob", is_nullable => 0 }, + "timestamp", + { + data_type => "timestamp", + datetime_undef_if_invalid => 1, + default_value => \"current_timestamp", + is_nullable => 0, + }, +); + +=head1 PRIMARY KEY + +=over 4 + +=item * L + +=back + +=cut + +__PACKAGE__->set_primary_key("imagenumber"); + +=head1 RELATIONS + +=head2 biblionumber + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "biblionumber", + "Koha::Schema::Result::Biblio", + { biblionumber => "biblionumber" }, + { + is_deferrable => 1, + join_type => "LEFT", + 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.07046 @ 2020-09-18 10:16:50 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:bcT7VxNm+4Uk+l03sM1MZg + + +# You can replace this text with custom code or comments, and it will be preserved on regeneration +1; diff --git a/Koha/Schema/Result/Item.pm b/Koha/Schema/Result/Item.pm index 7d8b9a6cc6..d4a6cc0478 100644 --- a/Koha/Schema/Result/Item.pm +++ b/Koha/Schema/Result/Item.pm @@ -548,6 +548,21 @@ __PACKAGE__->might_have( { cascade_copy => 0, cascade_delete => 0 }, ); +=head2 cover_images + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "cover_images", + "Koha::Schema::Result::CoverImage", + { "foreign.itemnumber" => "self.itemnumber" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + =head2 creator_batches Type: has_many @@ -754,8 +769,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.07046 @ 2020-06-05 20:21:47 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:9AxhV/hJnavWY4OTDTNRcQ +# Created by DBIx::Class::Schema::Loader v0.07046 @ 2020-09-18 10:16:50 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:kvv/3fnYpG3apwKs4/3ozg __PACKAGE__->belongs_to( biblioitem => "Koha::Schema::Result::Biblioitem", "biblioitemnumber" ); -- 2.20.1