From 76763a8e3854e7c0663c2248bf0a914165cb66c9 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 6 Feb 2025 10:48:13 +0000 Subject: [PATCH] Bug 26573: DBIC Schema --- Koha/Schema/Result/BorrowerAttributeType.pm | 60 ++++++++++----------- Koha/Schema/Result/Category.pm | 28 +++++++--- 2 files changed, 50 insertions(+), 38 deletions(-) diff --git a/Koha/Schema/Result/BorrowerAttributeType.pm b/Koha/Schema/Result/BorrowerAttributeType.pm index d5d4b9e31d5..7fbb4b328ff 100644 --- a/Koha/Schema/Result/BorrowerAttributeType.pm +++ b/Koha/Schema/Result/BorrowerAttributeType.pm @@ -111,15 +111,6 @@ foreign key from authorised_values that links this custom field to an authorized defines if this field displays in checkout screens -=head2 category_code - - data_type: 'varchar' - is_foreign_key: 1 - is_nullable: 1 - size: 10 - -defines a category for an attribute_type - =head2 class data_type: 'varchar' @@ -170,8 +161,6 @@ __PACKAGE__->add_columns( { data_type => "varchar", is_nullable => 1, size => 32 }, "display_checkout", { data_type => "tinyint", default_value => 0, is_nullable => 0 }, - "category_code", - { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 }, "class", { data_type => "varchar", default_value => "", is_nullable => 0, size => 255 }, "keep_for_pseudonymization", @@ -209,39 +198,34 @@ __PACKAGE__->has_many( { cascade_copy => 0, cascade_delete => 0 }, ); -=head2 borrower_attributes +=head2 borrower_attribute_types_categories Type: has_many -Related object: L +Related object: L =cut __PACKAGE__->has_many( - "borrower_attributes", - "Koha::Schema::Result::BorrowerAttribute", - { "foreign.code" => "self.code" }, + "borrower_attribute_types_categories", + "Koha::Schema::Result::BorrowerAttributeTypesCategory", + { "foreign.borrower_attribute_type_code" => "self.code" }, { cascade_copy => 0, cascade_delete => 0 }, ); -=head2 category_code +=head2 borrower_attributes -Type: belongs_to +Type: has_many -Related object: L +Related object: L =cut -__PACKAGE__->belongs_to( - "category_code", - "Koha::Schema::Result::Category", - { categorycode => "category_code" }, - { - is_deferrable => 1, - join_type => "LEFT", - on_delete => "RESTRICT", - on_update => "RESTRICT", - }, +__PACKAGE__->has_many( + "borrower_attributes", + "Koha::Schema::Result::BorrowerAttribute", + { "foreign.code" => "self.code" }, + { cascade_copy => 0, cascade_delete => 0 }, ); =head2 pseudonymized_borrower_attributes @@ -259,9 +243,23 @@ __PACKAGE__->has_many( { cascade_copy => 0, cascade_delete => 0 }, ); +=head2 categorycodes + +Type: many_to_many + +Composing rels: L -> categorycode + +=cut + +__PACKAGE__->many_to_many( + "categorycodes", + "borrower_attribute_types_categories", + "categorycode", +); + -# Created by DBIx::Class::Schema::Loader v0.07051 @ 2024-05-10 14:00:56 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ZmiiXHqRGV2SDb4IgSPvJQ +# Created by DBIx::Class::Schema::Loader v0.07051 @ 2025-02-06 10:47:55 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:jKC65zPRBCm2nn+tCW+FXg __PACKAGE__->add_columns( '+keep_for_pseudonymization' => { is_boolean => 1 }, diff --git a/Koha/Schema/Result/Category.pm b/Koha/Schema/Result/Category.pm index 25a0ba373a4..c7bfa8a69d0 100644 --- a/Koha/Schema/Result/Category.pm +++ b/Koha/Schema/Result/Category.pm @@ -309,18 +309,18 @@ __PACKAGE__->set_primary_key("categorycode"); =head1 RELATIONS -=head2 borrower_attribute_types +=head2 borrower_attribute_types_categories Type: has_many -Related object: L +Related object: L =cut __PACKAGE__->has_many( - "borrower_attribute_types", - "Koha::Schema::Result::BorrowerAttributeType", - { "foreign.category_code" => "self.categorycode" }, + "borrower_attribute_types_categories", + "Koha::Schema::Result::BorrowerAttributeTypesCategory", + { "foreign.categorycode" => "self.categorycode" }, { cascade_copy => 0, cascade_delete => 0 }, ); @@ -399,9 +399,23 @@ __PACKAGE__->has_many( { cascade_copy => 0, cascade_delete => 0 }, ); +=head2 borrower_attribute_type_codes + +Type: many_to_many + +Composing rels: L -> borrower_attribute_type_code + +=cut + +__PACKAGE__->many_to_many( + "borrower_attribute_type_codes", + "borrower_attribute_types_categories", + "borrower_attribute_type_code", +); + -# Created by DBIx::Class::Schema::Loader v0.07051 @ 2024-11-08 11:06:25 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:f8BSmD9RKHL/QAvHuuLIyw +# Created by DBIx::Class::Schema::Loader v0.07051 @ 2025-02-06 10:47:55 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:icPxRfjay5klakPb9qIoTA # You can replace this text with custom code or comments, and it will be preserved on regeneration -- 2.48.1