From cc1ec828c110a19edb61fa316d1399695d444b81 Mon Sep 17 00:00:00 2001 From: Liz Rea Date: Mon, 21 Sep 2015 14:30:47 +1200 Subject: [PATCH] Bug 14205: RM followup - DBIx updates --- Koha/Schema/Result/CourseItem.pm | 201 ++++++++++++++++++++++++++++ Koha/Schema/Result/CourseReserve.pm | 164 ++++++++++++++++++++++- 2 files changed, 362 insertions(+), 3 deletions(-) diff --git a/Koha/Schema/Result/CourseItem.pm b/Koha/Schema/Result/CourseItem.pm index a37263dd17..0082de1b57 100644 --- a/Koha/Schema/Result/CourseItem.pm +++ b/Koha/Schema/Result/CourseItem.pm @@ -133,6 +133,202 @@ __PACKAGE__->add_unique_constraint("itemnumber", ["itemnumber"]); =head1 RELATIONS +=head2 course_reserves + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "course_reserves", + "Koha::Schema::Result::CourseReserve", + { "foreign.ci_id" => "self.ci_id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + +=head2 holdingbranch + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "holdingbranch", + "Koha::Schema::Result::Branch", + { branchcode => "holdingbranch" }, + { + is_deferrable => 1, + join_type => "LEFT", + on_delete => "CASCADE", + on_update => "CASCADE", + }, +); + +=head2 itemnumber + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "itemnumber", + "Koha::Schema::Result::Item", + { itemnumber => "itemnumber" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, +); + + +# Created by DBIx::Class::Schema::Loader v0.07039 @ 2015-09-21 14:28:01 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:crMAu7kl9C9/D/S7WmYXfA +# These lines were loaded from '/home/liz/koha-src/koha/Koha/Schema/Result/CourseItem.pm' found in @INC. +# They are now part of the custom portion of this file +# for you to hand-edit. If you do not either delete +# this section or remove that file from @INC, this section +# will be repeated redundantly when you re-create this +# file again via Loader! See skip_load_external to disable +# this feature. + +use utf8; +package Koha::Schema::Result::CourseItem; + +# Created by DBIx::Class::Schema::Loader +# DO NOT MODIFY THE FIRST PART OF THIS FILE + +=head1 NAME + +Koha::Schema::Result::CourseItem + +=cut + +use strict; +use warnings; + +use base 'DBIx::Class::Core'; + +=head1 TABLE: C + +=cut + +__PACKAGE__->table("course_items"); + +=head1 ACCESSORS + +=head2 ci_id + + data_type: 'integer' + is_auto_increment: 1 + is_nullable: 0 + +=head2 itemnumber + + data_type: 'integer' + is_foreign_key: 1 + is_nullable: 0 + +=head2 itype + + data_type: 'varchar' + is_nullable: 1 + size: 10 + +=head2 ccode + + data_type: 'varchar' + is_nullable: 1 + size: 10 + +=head2 holdingbranch + + data_type: 'varchar' + is_foreign_key: 1 + is_nullable: 1 + size: 10 + +=head2 location + + data_type: 'varchar' + is_nullable: 1 + size: 80 + +=head2 enabled + + data_type: 'enum' + default_value: 'no' + extra: {list => ["yes","no"]} + is_nullable: 0 + +=head2 timestamp + + data_type: 'timestamp' + datetime_undef_if_invalid: 1 + default_value: current_timestamp + is_nullable: 0 + +=cut + +__PACKAGE__->add_columns( + "ci_id", + { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, + "itemnumber", + { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, + "itype", + { data_type => "varchar", is_nullable => 1, size => 10 }, + "ccode", + { data_type => "varchar", is_nullable => 1, size => 10 }, + "holdingbranch", + { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 }, + "location", + { data_type => "varchar", is_nullable => 1, size => 80 }, + "enabled", + { + data_type => "enum", + default_value => "no", + extra => { list => ["yes", "no"] }, + is_nullable => 0, + }, + "timestamp", + { + 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("ci_id"); + +=head1 UNIQUE CONSTRAINTS + +=head2 C + +=over 4 + +=item * L + +=back + +=cut + +__PACKAGE__->add_unique_constraint("itemnumber", ["itemnumber"]); + +=head1 RELATIONS + =head2 holdingbranch Type: belongs_to @@ -173,5 +369,10 @@ __PACKAGE__->belongs_to( # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:iVWZfUWcPfrLdLdvjyvbow +# You can replace this text with custom content, and it will be preserved on regeneration +1; +# End of lines loaded from '/home/liz/koha-src/koha/Koha/Schema/Result/CourseItem.pm' + + # You can replace this text with custom content, and it will be preserved on regeneration 1; diff --git a/Koha/Schema/Result/CourseReserve.pm b/Koha/Schema/Result/CourseReserve.pm index 9cfdfab7bc..b123100bba 100644 --- a/Koha/Schema/Result/CourseReserve.pm +++ b/Koha/Schema/Result/CourseReserve.pm @@ -38,6 +38,7 @@ __PACKAGE__->table("course_reserves"); =head2 ci_id data_type: 'integer' + is_foreign_key: 1 is_nullable: 0 =head2 staff_note @@ -65,7 +66,7 @@ __PACKAGE__->add_columns( "course_id", { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, "ci_id", - { data_type => "integer", is_nullable => 0 }, + { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, "staff_note", { data_type => "mediumtext", is_nullable => 1 }, "public_note", @@ -109,6 +110,21 @@ __PACKAGE__->add_unique_constraint("pseudo_key", ["course_id", "ci_id"]); =head1 RELATIONS +=head2 ci + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "ci", + "Koha::Schema::Result::CourseItem", + { ci_id => "ci_id" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, +); + =head2 course Type: belongs_to @@ -125,8 +141,150 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-07-11 09:26:55 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:SSTJhsNOuUlxr/CsDs08pQ +# Created by DBIx::Class::Schema::Loader v0.07039 @ 2015-09-21 14:28:01 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:g51SFJkD+JogzE02z+wJpQ +# These lines were loaded from '/home/liz/koha-src/koha/Koha/Schema/Result/CourseReserve.pm' found in @INC. +# They are now part of the custom portion of this file +# for you to hand-edit. If you do not either delete +# this section or remove that file from @INC, this section +# will be repeated redundantly when you re-create this +# file again via Loader! See skip_load_external to disable +# this feature. + +use utf8; +package Koha::Schema::Result::CourseReserve; + +# Created by DBIx::Class::Schema::Loader +# DO NOT MODIFY THE FIRST PART OF THIS FILE + +=head1 NAME + +Koha::Schema::Result::CourseReserve + +=cut + +use strict; +use warnings; + +use base 'DBIx::Class::Core'; + +=head1 TABLE: C + +=cut + +__PACKAGE__->table("course_reserves"); + +=head1 ACCESSORS + +=head2 cr_id + + data_type: 'integer' + is_auto_increment: 1 + is_nullable: 0 + +=head2 course_id + + data_type: 'integer' + is_foreign_key: 1 + is_nullable: 0 + +=head2 ci_id + + data_type: 'integer' + is_nullable: 0 + +=head2 staff_note + + data_type: 'mediumtext' + is_nullable: 1 + +=head2 public_note + + data_type: 'mediumtext' + is_nullable: 1 + +=head2 timestamp + + data_type: 'timestamp' + datetime_undef_if_invalid: 1 + default_value: current_timestamp + is_nullable: 0 + +=cut + +__PACKAGE__->add_columns( + "cr_id", + { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, + "course_id", + { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, + "ci_id", + { data_type => "integer", is_nullable => 0 }, + "staff_note", + { data_type => "mediumtext", is_nullable => 1 }, + "public_note", + { data_type => "mediumtext", is_nullable => 1 }, + "timestamp", + { + 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("cr_id"); + +=head1 UNIQUE CONSTRAINTS + +=head2 C + +=over 4 + +=item * L + +=item * L + +=back + +=cut + +__PACKAGE__->add_unique_constraint("pseudo_key", ["course_id", "ci_id"]); + +=head1 RELATIONS + +=head2 course + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "course", + "Koha::Schema::Result::Course", + { course_id => "course_id" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, +); + + +# Created by DBIx::Class::Schema::Loader v0.07025 @ 2013-10-14 20:56:21 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:9KuuUyFReuw+PAlLW84yXQ + + +# You can replace this text with custom content, and it will be preserved on regeneration +1; +# End of lines loaded from '/home/liz/koha-src/koha/Koha/Schema/Result/CourseReserve.pm' # You can replace this text with custom content, and it will be preserved on regeneration -- 2.39.5