Bugzilla – Attachment 137162 Details for
Bug 30275
Checkout renewals should be stored in their own table
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30275: (QA follow-up) Rename columns to match API
Bug-30275-QA-follow-up-Rename-columns-to-match-API.patch (text/plain), 9.42 KB, created by
Martin Renvoize (ashimema)
on 2022-07-05 12:37:52 UTC
(
hide
)
Description:
Bug 30275: (QA follow-up) Rename columns to match API
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2022-07-05 12:37:52 UTC
Size:
9.42 KB
patch
obsolete
>From 9fcbd9d4c1a4c9508292afd28398aecb5ebb5aa9 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 27 Apr 2022 17:07:01 -0300 >Subject: [PATCH] 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> >--- > C4/Circulation.pm | 8 +++--- > Koha/Checkouts/Renewal.pm | 27 +++++-------------- > 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 ++--- > 7 files changed, 29 insertions(+), 44 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 412bc92e90..76ef6add27 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -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(); > >diff --git a/Koha/Checkouts/Renewal.pm b/Koha/Checkouts/Renewal.pm >index e8a513d650..bb8c54992a 100644 >--- a/Koha/Checkouts/Renewal.pm >+++ b/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 >diff --git a/Koha/Schema/Result/CheckoutRenewal.pm b/Koha/Schema/Result/CheckoutRenewal.pm >index 2e230ca9a6..67a17aa132 100644 >--- a/Koha/Schema/Result/CheckoutRenewal.pm >+++ b/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</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", >diff --git a/Koha/Schema/Result/Issue.pm b/Koha/Schema/Result/Issue.pm >index 44debc944b..cd024b9de5 100644 >--- a/Koha/Schema/Result/Issue.pm >+++ b/Koha/Schema/Result/Issue.pm >@@ -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 }, > ); > >diff --git a/Koha/Schema/Result/OldIssue.pm b/Koha/Schema/Result/OldIssue.pm >index 1383033d31..759f7185e1 100644 >--- a/Koha/Schema/Result/OldIssue.pm >+++ b/Koha/Schema/Result/OldIssue.pm >@@ -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 }, > ); > >diff --git a/installer/data/mysql/atomicupdate/bug_30275.pl b/installer/data/mysql/atomicupdate/bug_30275.pl >index a77882c0dc..68ea87f83b 100755 >--- a/installer/data/mysql/atomicupdate/bug_30275.pl >+++ b/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; >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index a014bd3761..6ddaceec99 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -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; >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 30275
:
131593
|
131594
|
131595
|
131596
|
131597
|
131598
|
131599
|
131600
|
131601
|
131602
|
131603
|
131604
|
131605
|
131606
|
131607
|
131608
|
131609
|
131610
|
131611
|
131612
|
131613
|
131614
|
131615
|
131616
|
131879
|
131880
|
131881
|
131882
|
131883
|
131884
|
131885
|
131886
|
131887
|
131888
|
131889
|
131890
|
131897
|
131898
|
131899
|
131900
|
131901
|
131902
|
131903
|
131904
|
131905
|
131906
|
131907
|
131908
|
131909
|
131910
|
133908
|
133909
|
133910
|
133911
|
133912
|
133913
|
133914
|
133915
|
133916
|
133917
|
133918
|
133919
|
133920
|
133921
|
133922
|
133929
|
133930
|
133931
|
133932
|
133933
|
133934
|
133935
|
133936
|
133937
|
133938
|
133939
|
133940
|
133941
|
133942
|
133943
|
133944
|
133969
|
133970
|
133971
|
133972
|
133973
|
133974
|
133975
|
133976
|
133977
|
133978
|
133979
|
133980
|
133981
|
133982
|
133983
|
133984
|
134177
|
134178
|
134179
|
134180
|
134181
|
134182
|
134183
|
134184
|
134185
|
134186
|
134187
|
134188
|
134189
|
134190
|
134191
|
134192
|
134193
|
134210
|
134228
|
134229
|
134230
|
134231
|
134232
|
134233
|
134234
|
134235
|
134236
|
134237
|
134238
|
134239
|
134240
|
134241
|
134242
|
134243
|
134244
|
134245
|
134246
|
134247
|
134248
|
134470
|
134471
|
134472
|
134473
|
134869
|
134870
|
134871
|
134872
|
134873
|
134874
|
134875
|
134876
|
134877
|
134878
|
134879
|
134880
|
134881
|
134882
|
134883
|
134884
|
134885
|
134886
|
134887
|
134888
|
134889
|
135123
|
135124
|
135125
|
135126
|
135127
|
135128
|
135129
|
135130
|
135131
|
135132
|
135133
|
135134
|
135135
|
135136
|
135137
|
135138
|
135139
|
135140
|
135141
|
135142
|
135143
|
137146
|
137147
|
137148
|
137149
|
137150
|
137151
|
137152
|
137153
|
137154
|
137155
|
137156
|
137157
|
137158
|
137159
|
137160
|
137161
| 137162 |
137163
|
137164
|
137165
|
137166
|
137217
|
137598