From c984f42c94c621079d367e8363298cd8e74602d1 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 17 Apr 2023 20:48:16 +0200 Subject: [PATCH] Bug 30708: DBIC schema changes Sponsored-by: BULAC - http://www.bulac.fr/ Signed-off-by: BULAC - http://www.bulac.fr/ Signed-off-by: Heather Hernandez Signed-off-by: Laurence Rault Signed-off-by: Marcel de Rooy Signed-off-by: Tomas Cohen Arazi --- Koha/Schema/Result/Item.pm | 19 +- Koha/Schema/Result/PreservationProcessing.pm | 116 +++++++++++ .../Result/PreservationProcessingAttribute.pm | 137 ++++++++++++ .../PreservationProcessingAttributesItem.pm | 113 ++++++++++ Koha/Schema/Result/PreservationTrain.pm | 195 ++++++++++++++++++ Koha/Schema/Result/PreservationTrainsItem.pm | 195 ++++++++++++++++++ 6 files changed, 773 insertions(+), 2 deletions(-) create mode 100644 Koha/Schema/Result/PreservationProcessing.pm create mode 100644 Koha/Schema/Result/PreservationProcessingAttribute.pm create mode 100644 Koha/Schema/Result/PreservationProcessingAttributesItem.pm create mode 100644 Koha/Schema/Result/PreservationTrain.pm create mode 100644 Koha/Schema/Result/PreservationTrainsItem.pm diff --git a/Koha/Schema/Result/Item.pm b/Koha/Schema/Result/Item.pm index 3778fba936..d75c56ac9a 100644 --- a/Koha/Schema/Result/Item.pm +++ b/Koha/Schema/Result/Item.pm @@ -852,6 +852,21 @@ __PACKAGE__->has_many( { cascade_copy => 0, cascade_delete => 0 }, ); +=head2 preservation_trains_items + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "preservation_trains_items", + "Koha::Schema::Result::PreservationTrainsItem", + { "foreign.item_id" => "self.itemnumber" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + =head2 recalls Type: has_many @@ -943,8 +958,8 @@ __PACKAGE__->might_have( ); -# Created by DBIx::Class::Schema::Loader v0.07049 @ 2023-07-26 17:44:52 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:FHB+BvL4it4HrzlfNCxoKw +# Created by DBIx::Class::Schema::Loader v0.07049 @ 2023-07-31 11:33:55 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:w/riz2YWgVUds0eMqZuGTg __PACKAGE__->belongs_to( biblioitem => "Koha::Schema::Result::Biblioitem", "biblioitemnumber" ); diff --git a/Koha/Schema/Result/PreservationProcessing.pm b/Koha/Schema/Result/PreservationProcessing.pm new file mode 100644 index 0000000000..77002f7e76 --- /dev/null +++ b/Koha/Schema/Result/PreservationProcessing.pm @@ -0,0 +1,116 @@ +use utf8; +package Koha::Schema::Result::PreservationProcessing; + +# Created by DBIx::Class::Schema::Loader +# DO NOT MODIFY THE FIRST PART OF THIS FILE + +=head1 NAME + +Koha::Schema::Result::PreservationProcessing + +=cut + +use strict; +use warnings; + +use base 'DBIx::Class::Core'; + +=head1 TABLE: C + +=cut + +__PACKAGE__->table("preservation_processings"); + +=head1 ACCESSORS + +=head2 processing_id + + data_type: 'integer' + is_auto_increment: 1 + is_nullable: 0 + +primary key + +=head2 name + + data_type: 'varchar' + is_nullable: 0 + size: 80 + +name of the processing + +=cut + +__PACKAGE__->add_columns( + "processing_id", + { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, + "name", + { data_type => "varchar", is_nullable => 0, size => 80 }, +); + +=head1 PRIMARY KEY + +=over 4 + +=item * L + +=back + +=cut + +__PACKAGE__->set_primary_key("processing_id"); + +=head1 RELATIONS + +=head2 preservation_processing_attributes + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "preservation_processing_attributes", + "Koha::Schema::Result::PreservationProcessingAttribute", + { "foreign.processing_id" => "self.processing_id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + +=head2 preservation_trains + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "preservation_trains", + "Koha::Schema::Result::PreservationTrain", + { "foreign.default_processing_id" => "self.processing_id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + +=head2 preservation_trains_items + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "preservation_trains_items", + "Koha::Schema::Result::PreservationTrainsItem", + { "foreign.processing_id" => "self.processing_id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + + +# Created by DBIx::Class::Schema::Loader v0.07049 @ 2023-04-17 18:47:47 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:m7bHppTX3UpQY9CfmRPqQA + + +# You can replace this text with custom code or comments, and it will be preserved on regeneration +1; diff --git a/Koha/Schema/Result/PreservationProcessingAttribute.pm b/Koha/Schema/Result/PreservationProcessingAttribute.pm new file mode 100644 index 0000000000..bd704a0e8d --- /dev/null +++ b/Koha/Schema/Result/PreservationProcessingAttribute.pm @@ -0,0 +1,137 @@ +use utf8; +package Koha::Schema::Result::PreservationProcessingAttribute; + +# Created by DBIx::Class::Schema::Loader +# DO NOT MODIFY THE FIRST PART OF THIS FILE + +=head1 NAME + +Koha::Schema::Result::PreservationProcessingAttribute + +=cut + +use strict; +use warnings; + +use base 'DBIx::Class::Core'; + +=head1 TABLE: C + +=cut + +__PACKAGE__->table("preservation_processing_attributes"); + +=head1 ACCESSORS + +=head2 processing_attribute_id + + data_type: 'integer' + is_auto_increment: 1 + is_nullable: 0 + +primary key + +=head2 processing_id + + data_type: 'integer' + is_foreign_key: 1 + is_nullable: 0 + +link to the processing + +=head2 name + + data_type: 'varchar' + is_nullable: 0 + size: 80 + +name of the processing attribute + +=head2 type + + data_type: 'enum' + extra: {list => ["authorised_value","free_text","db_column"]} + is_nullable: 0 + +Type of the processing attribute + +=head2 option_source + + data_type: 'varchar' + is_nullable: 1 + size: 80 + +source of the possible options for this attribute + +=cut + +__PACKAGE__->add_columns( + "processing_attribute_id", + { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, + "processing_id", + { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, + "name", + { data_type => "varchar", is_nullable => 0, size => 80 }, + "type", + { + data_type => "enum", + extra => { list => ["authorised_value", "free_text", "db_column"] }, + is_nullable => 0, + }, + "option_source", + { data_type => "varchar", is_nullable => 1, size => 80 }, +); + +=head1 PRIMARY KEY + +=over 4 + +=item * L + +=back + +=cut + +__PACKAGE__->set_primary_key("processing_attribute_id"); + +=head1 RELATIONS + +=head2 preservation_processing_attributes_items + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "preservation_processing_attributes_items", + "Koha::Schema::Result::PreservationProcessingAttributesItem", + { + "foreign.processing_attribute_id" => "self.processing_attribute_id", + }, + { cascade_copy => 0, cascade_delete => 0 }, +); + +=head2 processing + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "processing", + "Koha::Schema::Result::PreservationProcessing", + { processing_id => "processing_id" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, +); + + +# Created by DBIx::Class::Schema::Loader v0.07049 @ 2023-04-17 18:47:47 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:i0vFmFYaqiZFyXGxDp+6oQ + + +# You can replace this text with custom code or comments, and it will be preserved on regeneration +1; diff --git a/Koha/Schema/Result/PreservationProcessingAttributesItem.pm b/Koha/Schema/Result/PreservationProcessingAttributesItem.pm new file mode 100644 index 0000000000..0ff4dae60c --- /dev/null +++ b/Koha/Schema/Result/PreservationProcessingAttributesItem.pm @@ -0,0 +1,113 @@ +use utf8; +package Koha::Schema::Result::PreservationProcessingAttributesItem; + +# Created by DBIx::Class::Schema::Loader +# DO NOT MODIFY THE FIRST PART OF THIS FILE + +=head1 NAME + +Koha::Schema::Result::PreservationProcessingAttributesItem + +=cut + +use strict; +use warnings; + +use base 'DBIx::Class::Core'; + +=head1 TABLE: C + +=cut + +__PACKAGE__->table("preservation_processing_attributes_items"); + +=head1 ACCESSORS + +=head2 processing_attribute_id + + data_type: 'integer' + is_foreign_key: 1 + is_nullable: 0 + +link with preservation_processing_attributes + +=head2 train_item_id + + data_type: 'integer' + is_foreign_key: 1 + is_nullable: 0 + +link with preservation_trains_items + +=head2 value + + data_type: 'varchar' + is_nullable: 1 + size: 255 + +value for this attribute + +=cut + +__PACKAGE__->add_columns( + "processing_attribute_id", + { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, + "train_item_id", + { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, + "value", + { data_type => "varchar", is_nullable => 1, size => 255 }, +); + +=head1 PRIMARY KEY + +=over 4 + +=item * L + +=item * L + +=back + +=cut + +__PACKAGE__->set_primary_key("processing_attribute_id", "train_item_id"); + +=head1 RELATIONS + +=head2 processing_attribute + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "processing_attribute", + "Koha::Schema::Result::PreservationProcessingAttribute", + { processing_attribute_id => "processing_attribute_id" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, +); + +=head2 train_item + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "train_item", + "Koha::Schema::Result::PreservationTrainsItem", + { train_item_id => "train_item_id" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, +); + + +# Created by DBIx::Class::Schema::Loader v0.07049 @ 2023-04-17 18:47:47 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:CiFAelBwfhQzRX1cL0ssqA + + +# You can replace this text with custom code or comments, and it will be preserved on regeneration +1; diff --git a/Koha/Schema/Result/PreservationTrain.pm b/Koha/Schema/Result/PreservationTrain.pm new file mode 100644 index 0000000000..9b51ee9f77 --- /dev/null +++ b/Koha/Schema/Result/PreservationTrain.pm @@ -0,0 +1,195 @@ +use utf8; +package Koha::Schema::Result::PreservationTrain; + +# Created by DBIx::Class::Schema::Loader +# DO NOT MODIFY THE FIRST PART OF THIS FILE + +=head1 NAME + +Koha::Schema::Result::PreservationTrain + +=cut + +use strict; +use warnings; + +use base 'DBIx::Class::Core'; + +=head1 TABLE: C + +=cut + +__PACKAGE__->table("preservation_trains"); + +=head1 ACCESSORS + +=head2 train_id + + data_type: 'integer' + is_auto_increment: 1 + is_nullable: 0 + +primary key + +=head2 name + + data_type: 'varchar' + is_nullable: 0 + size: 80 + +name of the train + +=head2 description + + data_type: 'varchar' + is_nullable: 1 + size: 255 + +description of the train + +=head2 default_processing_id + + data_type: 'integer' + is_foreign_key: 1 + is_nullable: 1 + +default processing, link to preservation_processings.processing_id + +=head2 not_for_loan + + data_type: 'varchar' + default_value: 0 + is_nullable: 0 + size: 80 + +NOT_LOAN authorised value to apply toitem added to this train + +=head2 created_on + + data_type: 'timestamp' + datetime_undef_if_invalid: 1 + default_value: current_timestamp + is_nullable: 0 + +creation date + +=head2 closed_on + + data_type: 'datetime' + datetime_undef_if_invalid: 1 + is_nullable: 1 + +closing date + +=head2 sent_on + + data_type: 'datetime' + datetime_undef_if_invalid: 1 + is_nullable: 1 + +sending date + +=head2 received_on + + data_type: 'datetime' + datetime_undef_if_invalid: 1 + is_nullable: 1 + +receiving date + +=cut + +__PACKAGE__->add_columns( + "train_id", + { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, + "name", + { data_type => "varchar", is_nullable => 0, size => 80 }, + "description", + { data_type => "varchar", is_nullable => 1, size => 255 }, + "default_processing_id", + { data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, + "not_for_loan", + { data_type => "varchar", default_value => 0, is_nullable => 0, size => 80 }, + "created_on", + { + data_type => "timestamp", + datetime_undef_if_invalid => 1, + default_value => \"current_timestamp", + is_nullable => 0, + }, + "closed_on", + { + data_type => "datetime", + datetime_undef_if_invalid => 1, + is_nullable => 1, + }, + "sent_on", + { + data_type => "datetime", + datetime_undef_if_invalid => 1, + is_nullable => 1, + }, + "received_on", + { + data_type => "datetime", + datetime_undef_if_invalid => 1, + is_nullable => 1, + }, +); + +=head1 PRIMARY KEY + +=over 4 + +=item * L + +=back + +=cut + +__PACKAGE__->set_primary_key("train_id"); + +=head1 RELATIONS + +=head2 default_processing + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "default_processing", + "Koha::Schema::Result::PreservationProcessing", + { processing_id => "default_processing_id" }, + { + is_deferrable => 1, + join_type => "LEFT", + on_delete => "SET NULL", + on_update => "CASCADE", + }, +); + +=head2 preservation_trains_items + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "preservation_trains_items", + "Koha::Schema::Result::PreservationTrainsItem", + { "foreign.train_id" => "self.train_id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + + +# Created by DBIx::Class::Schema::Loader v0.07049 @ 2023-04-17 18:47:47 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ojxQ0wFj2datCPVjeuTBWw + + +# You can replace this text with custom code or comments, and it will be preserved on regeneration +1; diff --git a/Koha/Schema/Result/PreservationTrainsItem.pm b/Koha/Schema/Result/PreservationTrainsItem.pm new file mode 100644 index 0000000000..78d197ec27 --- /dev/null +++ b/Koha/Schema/Result/PreservationTrainsItem.pm @@ -0,0 +1,195 @@ +use utf8; +package Koha::Schema::Result::PreservationTrainsItem; + +# Created by DBIx::Class::Schema::Loader +# DO NOT MODIFY THE FIRST PART OF THIS FILE + +=head1 NAME + +Koha::Schema::Result::PreservationTrainsItem + +=cut + +use strict; +use warnings; + +use base 'DBIx::Class::Core'; + +=head1 TABLE: C + +=cut + +__PACKAGE__->table("preservation_trains_items"); + +=head1 ACCESSORS + +=head2 train_item_id + + data_type: 'integer' + is_auto_increment: 1 + is_nullable: 0 + +primary key + +=head2 train_id + + data_type: 'integer' + is_foreign_key: 1 + is_nullable: 0 + +link with preservation_train + +=head2 item_id + + data_type: 'integer' + is_foreign_key: 1 + is_nullable: 0 + +link with items + +=head2 processing_id + + data_type: 'integer' + is_foreign_key: 1 + is_nullable: 1 + +specific processing for this item + +=head2 user_train_item_id + + data_type: 'integer' + is_nullable: 0 + +train item id for this train, starts from 1 + +=head2 added_on + + data_type: 'datetime' + datetime_undef_if_invalid: 1 + is_nullable: 1 + +added date + +=cut + +__PACKAGE__->add_columns( + "train_item_id", + { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, + "train_id", + { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, + "item_id", + { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, + "processing_id", + { data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, + "user_train_item_id", + { data_type => "integer", is_nullable => 0 }, + "added_on", + { + data_type => "datetime", + datetime_undef_if_invalid => 1, + is_nullable => 1, + }, +); + +=head1 PRIMARY KEY + +=over 4 + +=item * L + +=back + +=cut + +__PACKAGE__->set_primary_key("train_item_id"); + +=head1 UNIQUE CONSTRAINTS + +=head2 C + +=over 4 + +=item * L + +=item * L + +=back + +=cut + +__PACKAGE__->add_unique_constraint("train_id", ["train_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 preservation_processing_attributes_items + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "preservation_processing_attributes_items", + "Koha::Schema::Result::PreservationProcessingAttributesItem", + { "foreign.train_item_id" => "self.train_item_id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + +=head2 processing + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "processing", + "Koha::Schema::Result::PreservationProcessing", + { processing_id => "processing_id" }, + { + is_deferrable => 1, + join_type => "LEFT", + on_delete => "SET NULL", + on_update => "CASCADE", + }, +); + +=head2 train + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "train", + "Koha::Schema::Result::PreservationTrain", + { train_id => "train_id" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, +); + + +# Created by DBIx::Class::Schema::Loader v0.07049 @ 2023-04-17 18:47:47 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:lpvjaV+qXrIDVlimBaycgA + + +# You can replace this text with custom code or comments, and it will be preserved on regeneration +1; -- 2.39.5