@@ -, +, @@ --- C4/Circulation.pm | 8 +++--- Koha/Checkouts/Renewal.pm | 27 +++++-------------- Koha/Schema/Result/Borrower.pm | 4 +-- Koha/Schema/Result/CheckoutRenewal.pm | 22 +++++++-------- Koha/Schema/Result/Issue.pm | 2 +- Koha/Schema/Result/OldIssue.pm | 2 +- .../data/mysql/atomicupdate/bug_30275.pl | 6 ++--- installer/data/mysql/kohastructure.sql | 6 ++--- 8 files changed, 31 insertions(+), 46 deletions(-) --- a/C4/Circulation.pm +++ a/C4/Circulation.pm @@ -3215,10 +3215,10 @@ sub AddRenewal { # Add renewal record my $renewal = Koha::Checkouts::Renewal->new( { - issue_id => $issue->issue_id, - renewer_id => C4::Context->userenv->{'number'}, - seen => $seen, - interface => C4::Context->interface + checkout_id => $issue->issue_id, + renewer_id => C4::Context->userenv->{'number'}, + seen => $seen, + interface => C4::Context->interface } )->store(); --- a/Koha/Checkouts/Renewal.pm +++ a/Koha/Checkouts/Renewal.pm @@ -21,12 +21,11 @@ use Modern::Perl; use base qw(Koha::Object); -use Koha::Checkout; use Koha::Checkouts; -use Koha::Exceptions; use Koha::Exceptions::Checkouts::Renewals; +use Koha::Exceptions::Object; use Koha::Old::Checkouts; -use Koha::Patron; +use Koha::Patrons; =head1 NAME @@ -54,13 +53,13 @@ sub store { Koha::Exceptions::Checkouts::Renewals::NoRenewerID->throw(); } - unless ( ( !$self->issue_id && $self->in_storage ) - || Koha::Checkouts->find( $self->issue_id ) - || Koha::Old::Checkouts->find( $self->issue_id ) ) + unless ( ( !$self->checkout_id && $self->in_storage ) + || Koha::Checkouts->find( $self->checkout_id ) + || Koha::Old::Checkouts->find( $self->checkout_id ) ) { Koha::Exceptions::Object::FKConstraint->throw( error => 'Broken FK constraint', - broken_fk => 'issue_id' + broken_fk => 'checkout_id' ); } @@ -102,20 +101,6 @@ sub renewer { return Koha::Patron->_new_from_dbic( $renewer ) if $renewer; } -=head3 to_api_mapping - -This method returns the mapping for representing a Koha::Checkouts::Renewal object -on the API. - -=cut - -sub to_api_mapping { - return { - id => 'renewal_id', - issue_id => 'checkout_id' - }; -} - =head2 Internal methods =head3 _type --- a/Koha/Schema/Result/Borrower.pm +++ a/Koha/Schema/Result/Borrower.pm @@ -1980,8 +1980,8 @@ Composing rels: L -> permission __PACKAGE__->many_to_many("permissions", "user_permissions", "permission"); -# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-05-06 19:32:13 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:lGlRQ4XvRdsrqTye6sDpYg +# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-04-27 19:43:17 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:75KmxqXqexvJ93e4awqwbw __PACKAGE__->has_many( "extended_attributes", --- a/Koha/Schema/Result/CheckoutRenewal.pm +++ a/Koha/Schema/Result/CheckoutRenewal.pm @@ -23,18 +23,18 @@ __PACKAGE__->table("checkout_renewals"); =head1 ACCESSORS -=head2 id +=head2 renewal_id data_type: 'integer' is_auto_increment: 1 is_nullable: 0 -=head2 issue_id +=head2 checkout_id data_type: 'integer' is_nullable: 1 -the id of the issue this renewal pertains to +the id of the checkout this renewal pertains to =head2 renewer_id @@ -72,9 +72,9 @@ the date and time the renewal took place =cut __PACKAGE__->add_columns( - "id", + "renewal_id", { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, - "issue_id", + "checkout_id", { data_type => "integer", is_nullable => 1 }, "renewer_id", { data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, @@ -95,13 +95,13 @@ __PACKAGE__->add_columns( =over 4 -=item * L +=item * L =back =cut -__PACKAGE__->set_primary_key("id"); +__PACKAGE__->set_primary_key("renewal_id"); =head1 RELATIONS @@ -126,8 +126,8 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-03-11 16:33:50 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:agLgLnVeKYB5wdWS06xD0A +# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-04-27 19:43:17 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:7mjiEx634L5FZyjroACUkg =head2 checkout @@ -140,7 +140,7 @@ Related object: L __PACKAGE__->belongs_to( "checkout", "Koha::Schema::Result::Issue", - { issue_id => "issue_id" }, + { issue_id => "checkout_id" }, { is_deferrable => 1, join_type => "LEFT", @@ -158,7 +158,7 @@ Related object: L __PACKAGE__->belongs_to( "old_checkout", "Koha::Schema::Result::OldIssue", - { issue_id => "issue_id" }, + { issue_id => "checkout_id" }, { is_deferrable => 1, join_type => "LEFT", --- a/Koha/Schema/Result/Issue.pm +++ a/Koha/Schema/Result/Issue.pm @@ -384,7 +384,7 @@ Related object: L __PACKAGE__->has_many( "renewals", "Koha::Schema::Result::CheckoutRenewal", - { "foreign.issue_id" => "self.issue_id" }, + { "foreign.checkout_id" => "self.issue_id" }, { cascade_copy => 0, cascade_delete => 0 }, ); --- a/Koha/Schema/Result/OldIssue.pm +++ a/Koha/Schema/Result/OldIssue.pm @@ -354,7 +354,7 @@ Related object: L __PACKAGE__->has_many( "renewals", "Koha::Schema::Result::CheckoutRenewal", - { "foreign.issue_id" => "self.issue_id" }, + { "foreign.checkout_id" => "self.issue_id" }, { cascade_copy => 0, cascade_delete => 0 }, ); --- a/installer/data/mysql/atomicupdate/bug_30275.pl +++ a/installer/data/mysql/atomicupdate/bug_30275.pl @@ -9,13 +9,13 @@ return { unless ( TableExists('checkout_renewals') ) { $dbh->do(q{ CREATE TABLE `checkout_renewals` ( - `id` int(11) NOT NULL auto_increment, - `issue_id` int(11) DEFAULT NULL COMMENT 'the id of the issue this renewal pertains to', + `renewal_id` int(11) NOT NULL auto_increment, + `checkout_id` int(11) DEFAULT NULL COMMENT 'the id of the checkout this renewal pertains to', `renewer_id` int(11) DEFAULT NULL COMMENT 'the id of the user who processed the renewal', `seen` tinyint(1) DEFAULT 0 COMMENT 'boolean denoting whether the item was present or not', `interface` varchar(16) NOT NULL COMMENT 'the interface this renewal took place on', `timestamp` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'the date and time the renewal took place', - PRIMARY KEY(`id`), + PRIMARY KEY(`renewal_id`), KEY `renewer_id` (`renewer_id`), CONSTRAINT `renewals_renewer_id` FOREIGN KEY (`renewer_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; --- a/installer/data/mysql/kohastructure.sql +++ a/installer/data/mysql/kohastructure.sql @@ -1698,13 +1698,13 @@ DROP TABLE IF EXISTS `checkout_renewals`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `checkout_renewals` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `issue_id` int(11) DEFAULT NULL COMMENT 'the id of the issue this renewal pertains to', + `renewal_id` int(11) NOT NULL AUTO_INCREMENT, + `checkout_id` int(11) DEFAULT NULL COMMENT 'the id of the checkout this renewal pertains to', `renewer_id` int(11) DEFAULT NULL COMMENT 'the id of the user who processed the renewal', `seen` tinyint(1) DEFAULT 0 COMMENT 'boolean denoting whether the item was present or not', `interface` varchar(16) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'the interface this renewal took place on', `timestamp` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'the date and time the renewal took place', - PRIMARY KEY (`id`), + PRIMARY KEY (`renewal_id`), KEY `renewer_id` (`renewer_id`), CONSTRAINT `renewals_renewer_id` FOREIGN KEY (`renewer_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; --