From 1f5e540a5f82ee5077be01f163eec5bd45aa333b Mon Sep 17 00:00:00 2001 From: Lari Taskula Date: Fri, 1 Dec 2023 16:30:15 +0000 Subject: [PATCH] Bug 35471: DBIx changes Sponsored-by: Hypernova Oy --- Koha/Schema/Result/BiblioFramework.pm | 49 +++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/Koha/Schema/Result/BiblioFramework.pm b/Koha/Schema/Result/BiblioFramework.pm index 15755315d2..50294609bb 100644 --- a/Koha/Schema/Result/BiblioFramework.pm +++ b/Koha/Schema/Result/BiblioFramework.pm @@ -32,6 +32,13 @@ __PACKAGE__->table("biblio_framework"); the unique code assigned to the framework +=head2 parent_frameworkcode + + data_type: 'varchar' + is_foreign_key: 1 + is_nullable: 1 + size: 4 + =head2 frameworktext data_type: 'varchar' @@ -46,6 +53,8 @@ the description/name given to the framework __PACKAGE__->add_columns( "frameworkcode", { data_type => "varchar", default_value => "", is_nullable => 0, size => 4 }, + "parent_frameworkcode", + { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 4 }, "frameworktext", { data_type => "varchar", default_value => "", is_nullable => 0, size => 255 }, ); @@ -62,9 +71,45 @@ __PACKAGE__->add_columns( __PACKAGE__->set_primary_key("frameworkcode"); +=head1 RELATIONS + +=head2 biblio_frameworks + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "biblio_frameworks", + "Koha::Schema::Result::BiblioFramework", + { "foreign.parent_frameworkcode" => "self.frameworkcode" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + +=head2 parent_frameworkcode + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "parent_frameworkcode", + "Koha::Schema::Result::BiblioFramework", + { frameworkcode => "parent_frameworkcode" }, + { + is_deferrable => 1, + join_type => "LEFT", + on_delete => "SET NULL", + on_update => "CASCADE", + }, +); -# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-01-21 13:39:29 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:YdCNaeY5v1WcfcDuA6xE0w +# Created by DBIx::Class::Schema::Loader v0.07051 @ 2023-12-01 16:19:52 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Ac+E/s6Yov29CJKDGovgNw # FIXME This should not be needed, we need to add the FK at DB level # It cannot be done now because the default framework (frameworkcode=='') -- 2.34.1