From 35ab9f625db698670a52d2027997a41070b09cef Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 28 Feb 2023 17:39:40 +0100 Subject: [PATCH] Bug 31383: DBIC changes Sponsored-by: Rijksmuseum, Netherlands Signed-off-by: Marcel de Rooy Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi --- Koha/Schema/Result/AdditionalContent.pm | 64 +++----- .../Result/AdditionalContentsLocalization.pm | 148 ++++++++++++++++++ 2 files changed, 171 insertions(+), 41 deletions(-) create mode 100644 Koha/Schema/Result/AdditionalContentsLocalization.pm diff --git a/Koha/Schema/Result/AdditionalContent.pm b/Koha/Schema/Result/AdditionalContent.pm index 598f17ccc0..c559107ca7 100644 --- a/Koha/Schema/Result/AdditionalContent.pm +++ b/Koha/Schema/Result/AdditionalContent.pm @@ -23,14 +23,14 @@ __PACKAGE__->table("additional_contents"); =head1 ACCESSORS -=head2 idnew +=head2 id data_type: 'integer' extra: {unsigned => 1} is_auto_increment: 1 is_nullable: 0 -unique identifier for the additional content +unique identifier for the additional content category =head2 category @@ -65,31 +65,6 @@ location of the additional content branch code users to create branch specific additional content, NULL is every branch. -=head2 title - - data_type: 'varchar' - default_value: (empty string) - is_nullable: 0 - size: 250 - -title of the additional content - -=head2 content - - data_type: 'mediumtext' - is_nullable: 0 - -the body of your additional content - -=head2 lang - - data_type: 'varchar' - default_value: (empty string) - is_nullable: 0 - size: 50 - -location for the additional content(koha is the staff interface, slip is the circulation receipt and language codes are for the opac) - =head2 published_on data_type: 'date' @@ -133,7 +108,7 @@ The user who created the additional content =cut __PACKAGE__->add_columns( - "idnew", + "id", { data_type => "integer", extra => { unsigned => 1 }, @@ -148,12 +123,6 @@ __PACKAGE__->add_columns( { data_type => "varchar", is_nullable => 0, size => 255 }, "branchcode", { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 }, - "title", - { data_type => "varchar", default_value => "", is_nullable => 0, size => 250 }, - "content", - { data_type => "mediumtext", is_nullable => 0 }, - "lang", - { data_type => "varchar", default_value => "", is_nullable => 0, size => 50 }, "published_on", { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 }, "updated_on", @@ -175,13 +144,13 @@ __PACKAGE__->add_columns( =over 4 -=item * L +=item * L =back =cut -__PACKAGE__->set_primary_key("idnew"); +__PACKAGE__->set_primary_key("id"); =head1 UNIQUE CONSTRAINTS @@ -195,19 +164,32 @@ __PACKAGE__->set_primary_key("idnew"); =item * L -=item * L - =back =cut __PACKAGE__->add_unique_constraint( "additional_contents_uniq", - ["category", "code", "branchcode", "lang"], + ["category", "code", "branchcode"], ); =head1 RELATIONS +=head2 additional_contents_localizations + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "additional_contents_localizations", + "Koha::Schema::Result::AdditionalContentsLocalization", + { "foreign.additional_content_id" => "self.id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + =head2 borrowernumber Type: belongs_to @@ -249,8 +231,8 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-02-02 07:12:59 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:/h/wWfmyVxW7skwrMn3scg +# Created by DBIx::Class::Schema::Loader v0.07049 @ 2023-03-03 07:19:57 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:0w/fOUAy+4V4aVls/i7Wig # You can replace this text with custom code or comments, and it will be preserved on regeneration diff --git a/Koha/Schema/Result/AdditionalContentsLocalization.pm b/Koha/Schema/Result/AdditionalContentsLocalization.pm new file mode 100644 index 0000000000..773965ccbb --- /dev/null +++ b/Koha/Schema/Result/AdditionalContentsLocalization.pm @@ -0,0 +1,148 @@ +use utf8; +package Koha::Schema::Result::AdditionalContentsLocalization; + +# Created by DBIx::Class::Schema::Loader +# DO NOT MODIFY THE FIRST PART OF THIS FILE + +=head1 NAME + +Koha::Schema::Result::AdditionalContentsLocalization + +=cut + +use strict; +use warnings; + +use base 'DBIx::Class::Core'; + +=head1 TABLE: C + +=cut + +__PACKAGE__->table("additional_contents_localizations"); + +=head1 ACCESSORS + +=head2 id + + data_type: 'integer' + extra: {unsigned => 1} + is_auto_increment: 1 + is_nullable: 0 + +unique identifier for the additional content + +=head2 additional_content_id + + data_type: 'integer' + extra: {unsigned => 1} + is_foreign_key: 1 + is_nullable: 0 + +link to the additional content + +=head2 title + + data_type: 'varchar' + default_value: (empty string) + is_nullable: 0 + size: 250 + +title of the additional content + +=head2 content + + data_type: 'mediumtext' + is_nullable: 0 + +the body of your additional content + +=head2 lang + + data_type: 'varchar' + default_value: (empty string) + is_nullable: 0 + size: 50 + +lang + +=cut + +__PACKAGE__->add_columns( + "id", + { + data_type => "integer", + extra => { unsigned => 1 }, + is_auto_increment => 1, + is_nullable => 0, + }, + "additional_content_id", + { + data_type => "integer", + extra => { unsigned => 1 }, + is_foreign_key => 1, + is_nullable => 0, + }, + "title", + { data_type => "varchar", default_value => "", is_nullable => 0, size => 250 }, + "content", + { data_type => "mediumtext", is_nullable => 0 }, + "lang", + { data_type => "varchar", default_value => "", is_nullable => 0, size => 50 }, +); + +=head1 PRIMARY KEY + +=over 4 + +=item * L + +=back + +=cut + +__PACKAGE__->set_primary_key("id"); + +=head1 UNIQUE CONSTRAINTS + +=head2 C + +=over 4 + +=item * L + +=item * L + +=back + +=cut + +__PACKAGE__->add_unique_constraint( + "additional_contents_localizations_uniq", + ["additional_content_id", "lang"], +); + +=head1 RELATIONS + +=head2 additional_content + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "additional_content", + "Koha::Schema::Result::AdditionalContent", + { id => "additional_content_id" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, +); + + +# Created by DBIx::Class::Schema::Loader v0.07049 @ 2023-03-08 08:09:35 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:KRaaWslsavWVmDbZF/NwcQ + + +# You can replace this text with custom code or comments, and it will be preserved on regeneration +1; -- 2.39.5