From 06a2e4bb5400fddd4c88b461cef593d92965dd03 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 8 Mar 2022 11:29:15 +0000 Subject: [PATCH] Bug 24857: DO NOT PUSH: Schema changes --- Koha/Schema/Result/Biblio.pm | 19 +++- Koha/Schema/Result/Item.pm | 19 +++- Koha/Schema/Result/ItemGroup.pm | 161 ++++++++++++++++++++++++++++ Koha/Schema/Result/ItemGroupItem.pm | 142 ++++++++++++++++++++++++ 4 files changed, 337 insertions(+), 4 deletions(-) create mode 100644 Koha/Schema/Result/ItemGroup.pm create mode 100644 Koha/Schema/Result/ItemGroupItem.pm diff --git a/Koha/Schema/Result/Biblio.pm b/Koha/Schema/Result/Biblio.pm index 10e717b369..1b66570f34 100644 --- a/Koha/Schema/Result/Biblio.pm +++ b/Koha/Schema/Result/Biblio.pm @@ -315,6 +315,21 @@ __PACKAGE__->has_many( { cascade_copy => 0, cascade_delete => 0 }, ); +=head2 item_groups + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "item_groups", + "Koha::Schema::Result::ItemGroup", + { "foreign.biblio_id" => "self.biblionumber" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + =head2 items Type: has_many @@ -526,8 +541,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-09-20 12:00:15 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:troBZEbpX+2RhgH2jptVZQ +# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-03-07 15:59:20 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:m1QMpWvK/E2MXuZXs4jHoQ __PACKAGE__->has_many( "biblioitem", diff --git a/Koha/Schema/Result/Item.pm b/Koha/Schema/Result/Item.pm index a53e10e98a..e0eccb3f8a 100644 --- a/Koha/Schema/Result/Item.pm +++ b/Koha/Schema/Result/Item.pm @@ -729,6 +729,21 @@ __PACKAGE__->might_have( { cascade_copy => 0, cascade_delete => 0 }, ); +=head2 item_group_item + +Type: might_have + +Related object: L + +=cut + +__PACKAGE__->might_have( + "item_group_item", + "Koha::Schema::Result::ItemGroupItem", + { "foreign.item_id" => "self.itemnumber" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + =head2 items_last_borrower Type: might_have @@ -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-01 12:52:33 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:WeRY0B6a1D94WckYmUgWpQ __PACKAGE__->belongs_to( biblioitem => "Koha::Schema::Result::Biblioitem", "biblioitemnumber" ); diff --git a/Koha/Schema/Result/ItemGroup.pm b/Koha/Schema/Result/ItemGroup.pm new file mode 100644 index 0000000000..753f6e69be --- /dev/null +++ b/Koha/Schema/Result/ItemGroup.pm @@ -0,0 +1,161 @@ +use utf8; +package Koha::Schema::Result::ItemGroup; + +# Created by DBIx::Class::Schema::Loader +# DO NOT MODIFY THE FIRST PART OF THIS FILE + +=head1 NAME + +Koha::Schema::Result::ItemGroup + +=cut + +use strict; +use warnings; + +use base 'DBIx::Class::Core'; + +=head1 TABLE: C + +=cut + +__PACKAGE__->table("item_groups"); + +=head1 ACCESSORS + +=head2 item_group_id + + data_type: 'integer' + is_auto_increment: 1 + is_nullable: 0 + +id for the items group + +=head2 biblio_id + + data_type: 'integer' + default_value: 0 + is_foreign_key: 1 + is_nullable: 0 + +id for the bibliographic record the group belongs to + +=head2 display_order + + data_type: 'integer' + default_value: 0 + is_nullable: 0 + +The 'sort order' for item_groups + +=head2 description + + data_type: 'mediumtext' + is_nullable: 1 + +A group description + +=head2 created_on + + data_type: 'timestamp' + datetime_undef_if_invalid: 1 + is_nullable: 1 + +Time and date the group was created + +=head2 updated_on + + data_type: 'timestamp' + datetime_undef_if_invalid: 1 + default_value: current_timestamp + is_nullable: 0 + +Time and date of the latest change on the group + +=cut + +__PACKAGE__->add_columns( + "item_group_id", + { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, + "biblio_id", + { + data_type => "integer", + default_value => 0, + is_foreign_key => 1, + is_nullable => 0, + }, + "display_order", + { data_type => "integer", default_value => 0, is_nullable => 0 }, + "description", + { data_type => "mediumtext", is_nullable => 1 }, + "created_on", + { + data_type => "timestamp", + datetime_undef_if_invalid => 1, + is_nullable => 1, + }, + "updated_on", + { + 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("item_group_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_group_items + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "item_group_items", + "Koha::Schema::Result::ItemGroupItem", + { "foreign.item_group_id" => "self.item_group_id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + + +# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-09-01 12:37:33 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:uB7PHJt6WQHMv/saTCpkOw + +sub koha_object_class { + 'Koha::Biblio::ItemGroup'; +} +sub koha_objects_class { + 'Koha::Biblio::ItemGroups'; +} + +1; diff --git a/Koha/Schema/Result/ItemGroupItem.pm b/Koha/Schema/Result/ItemGroupItem.pm new file mode 100644 index 0000000000..33a0939f4b --- /dev/null +++ b/Koha/Schema/Result/ItemGroupItem.pm @@ -0,0 +1,142 @@ +use utf8; +package Koha::Schema::Result::ItemGroupItem; + +# Created by DBIx::Class::Schema::Loader +# DO NOT MODIFY THE FIRST PART OF THIS FILE + +=head1 NAME + +Koha::Schema::Result::ItemGroupItem + +=cut + +use strict; +use warnings; + +use base 'DBIx::Class::Core'; + +=head1 TABLE: C + +=cut + +__PACKAGE__->table("item_group_items"); + +=head1 ACCESSORS + +=head2 item_group_items_id + + data_type: 'integer' + is_auto_increment: 1 + is_nullable: 0 + +id for the group/item link + +=head2 item_group_id + + data_type: 'integer' + default_value: 0 + is_foreign_key: 1 + is_nullable: 0 + +foreign key making this table a 1 to 1 join from items to item groups + +=head2 item_id + + data_type: 'integer' + default_value: 0 + is_foreign_key: 1 + is_nullable: 0 + +foreign key linking this table to the items table + +=cut + +__PACKAGE__->add_columns( + "item_group_items_id", + { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, + "item_group_id", + { + data_type => "integer", + default_value => 0, + is_foreign_key => 1, + is_nullable => 0, + }, + "item_id", + { + data_type => "integer", + default_value => 0, + is_foreign_key => 1, + is_nullable => 0, + }, +); + +=head1 PRIMARY KEY + +=over 4 + +=item * L + +=back + +=cut + +__PACKAGE__->set_primary_key("item_group_items_id"); + +=head1 UNIQUE CONSTRAINTS + +=head2 C + +=over 4 + +=item * L + +=back + +=cut + +__PACKAGE__->add_unique_constraint("item_id", ["item_id"]); + +=head1 RELATIONS + +=head2 item + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "item", + "Koha::Schema::Result::Item", + { itemnumber => "item_id" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, +); + +=head2 item_group + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "item_group", + "Koha::Schema::Result::ItemGroup", + { item_group_id => "item_group_id" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, +); + + +# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-09-01 12:52:33 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:y9cE5sPmUxcJFgAZfsEQsg + +sub koha_object_class { + 'Koha::Biblio::ItemGroup::Item'; +} +sub koha_objects_class { + 'Koha::Biblio::ItemGroup::Items'; +} + +1; -- 2.30.2