Bug 30275: (QA follow-up) Rename columns to match API
This patch performs the following column renames: * id => renewal_id * issue_id => checkout_id The idea is that no translation is needed for the API, and also, being a new table, we can educate the users into the 'to be' terminology we are leaning towards, instead of having them learn one naming to create reports and then need to translate them once we normalize things in a future. That said, this is simple to review. Apply this patch and repeat the test plan. Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
cefbaca591
commit
61e41c4c41
|
|
@ -3220,10 +3220,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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1989,8 +1989,8 @@ Composing rels: L</user_permissions> -> permission
|
|||
__PACKAGE__->many_to_many("permissions", "user_permissions", "permission");
|
||||
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-06-24 15:30:00
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:8f/ch5BjQ1LL9jrEvegkmA
|
||||
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-07-05 12:41:19
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:e5ZH2Ise5JLYRXrq22L9rw
|
||||
|
||||
__PACKAGE__->has_many(
|
||||
"extended_attributes",
|
||||
|
|
|
|||
|
|
@ -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</id>
|
||||
=item * L</renewal_id>
|
||||
|
||||
=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<Koha::Schema::Result::Issue>
|
|||
__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<Koha::Schema::Result::OldIssue>
|
|||
__PACKAGE__->belongs_to(
|
||||
"old_checkout",
|
||||
"Koha::Schema::Result::OldIssue",
|
||||
{ issue_id => "issue_id" },
|
||||
{ issue_id => "checkout_id" },
|
||||
{
|
||||
is_deferrable => 1,
|
||||
join_type => "LEFT",
|
||||
|
|
|
|||
|
|
@ -384,7 +384,7 @@ Related object: L<Koha::Schema::Result::CheckoutRenewal>
|
|||
__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 },
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -354,7 +354,7 @@ Related object: L<Koha::Schema::Result::CheckoutRenewal>
|
|||
__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 },
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -1703,13 +1703,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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue